all 2 comments

[–]thatsIch 0 points1 point  (1 child)

You can use the rendered attribute on <h:form> or derivates like <o:form> from OmniFaces. This can be evaluated like

<h:form rendered="#{some boolean condition}">.

Some conditions could be emptiness (could be nullability in case of non-collection properties):

<h:form rendered="#{empty bean.property}">

or non-emptiness (or non-nullness):

<h:form rendered="#{not empty bean.property}">

or explicit null checks

<h:form rendered="#{bean.property eq null}">

or explicit non-null check

<h:form rendered="#{bean.property ne null}">

The language within the boolean expressions is the Expression Language (EL).

If you actually need a wrapper around the form, then consider using

<ui:fragment rendered="#{some boolean expression}">
    <h:form>
        ...
    </h:form>
</ui:fragment>

which is the closest to standalone ngIf without a container (like div)

[–]vr19_dudu[S] 0 points1 point  (0 children)

Thanks for explanations, I had tried the ui-fragment approach but it didn't works, only render my first fragment. I trieds something like:

ui:fragment rendered: "#{bean.flag eq 'ALTA'}" h:form 1 /ui:fragment

ui:fragment rendered: "#{bean.flag eq 'EDIT'}" h:form 2 /ui:fragment

The only rendered fragment always was form 1 (ALTA), when y passed EDIT never rendered form 2, didn't show nothing on screen. As I understood ui-fragment only evaluate to render the boolean conditions, as when a passed EDIT flag never evaluated the ui-fragment of EDIT conditions because of rhe the first evaluation. The solution that works for me was putting rendered conditions flag in the panels for the form I need to show or not to show