1

In my JSF 2.2 application on Glassfish 4.0, i need to allow update of single fields within a page.

For each field, i created a h:form containing two ui:fragments.

Each of there fragments is rendered based on the value of a boolean edit attribute named enteEdit in my backing bean FascicoloDettaglio.

FascicoloDettaglio is @ViewScoped.

The first fragment contains an h:outputText with the value from my bean, and a h:commandLink used to update the edit attribute and fire an AJAX request to re-render the form, which causes the first fragment to disappear and the second fragment to appear.

The second fragment contains the h:inputText used to edit the field, and the submit h:commandButton, which resets the edit attribute and then AJAX-calls the action method.

However, the second button never works; the action is not called and the button simply does nothing; while it should call the action and then re-render the entire form, turning the second fragment off and the first on.

I can't understand why it doesn't work.

This is the JSF code fragment:

<h:form>
    <ui:fragment rendered="#{not fascicoloDettaglio.enteEdit}">
        <h:outputText value="#{fascicoloDettaglio.fascicolo.ente}" />
        <h:commandLink rendered="#{request.isUserInRole('affgen')}">
            <h:graphicImage name="img/modify.png" width="24" height="24" title="Modifica" />
            <f:ajax render="@form" />
            <f:setPropertyActionListener target="#{fascicoloDettaglio.enteEdit}" value="true" />
            <f:setPropertyActionListener target="#{fascicoloDettaglio.ente}" value="#{fascicoloDettaglio.fascicolo.ente}" />
        </h:commandLink>
    </ui:fragment>
    <ui:fragment rendered="#{fascicoloDettaglio.enteEdit}">
        <h:inputText value="#{fascicoloDettaglio.ente}" requiredMessage="Introdurre l'ente ricorrente." required="true" styleClass="largetext #{component.valid ? '' : 'inputvalidationerror'}">
            <f:validateLength maximum="255" />
        </h:inputText>
        <h:commandButton action="#{fascicoloDettaglio.salvaEnte}" value="Salva">
            <f:setPropertyActionListener target="#{fascicoloDettaglio.enteEdit}" value="false" />
            <f:ajax execute="@form" render="@form" />
        </h:commandButton>
        <h:messages />
    </ui:fragment>
</h:form>

Any help would be very appreciated.

Valentino
  • 138
  • 1
  • 6
  • Already refer to the checklist in this answer: http://stackoverflow.com/a/2120183/696299 – Rami Mar 06 '14 at 16:34
  • The only one to check is no. 5, but it doesn't apply since the rendered attribute of the parent evaluates to false only during update model. – Valentino Mar 06 '14 at 17:48
  • Or perhaps setpropertyactionlistener works during apply request phase? I'll check moving the property set in the bean code. – Valentino Mar 06 '14 at 18:18

0 Answers0