开发者

JSF render is not working for form element

开发者 https://www.devze.com 2023-03-26 10:19 出处:网络
I have a composite displayed inside a dialog. I have an edit button that get the current bean @SessionScoped (item in a data table) and then update the UI. My app is very similar to a simple CRUD app

I have a composite displayed inside a dialog. I have an edit button that get the current bean @SessionScoped (item in a data table) and then update the UI. My app is very similar to a simple CRUD app like http://balusc.blogspot.com/2010/06/benefits-and-pitfalls-of-viewscoped.html.

The problem is that the UI is updated correctly when using <h:outputText/> but not when using a form element.

<h:inputTextarea value="#{cc.attrs.managedBean.assertionStatement}" />
<h:inputText value="#{cc.attrs.managedBean.assertionStatement}" />
<h:outputText value="#{cc.attrs.managedBean.assertionStatement}"/>

The UI shows an empty textarea and input but the outputText renders the correct value. The getAssertionStatement() is called 3 times which seems to be the correct behavior.

When I close the dialog and reopen it, everything (form element) is populated.

The dialog call (ag namespace is for composite component):

    <p:dialog widgetVar="DataValueRuleDialog" modal="true" height="600" width="800">
        <p:outputPanel id="DataValueRulePanel">
            <ag:DataValueAssertion managedBean="#{dataValueAssertionController}" id="DataValueComposite" />
        </p:outputPanel>
    </p:dialog>

The composite that calls another composite:

    <h:form id="DataValueForm">
        <ag:assertionMetadataComponent
            managedBean="#{cc.attrs.managedBean.dataValueAssertionBean.assertionMetadataBean}"
            assertionStatementRows="5" />

        <p:dataTable value="#{cc.attrs.managedBean.model}" var="item">
            <p:column>
                <f:facet name="header">Assertion Statement</f:facet>
                <h:outputText rendered="#{item.profileBean.profileLocation == cc.attrs.managedBean.selectedComformanceProfile.name}" value="#{item.assertionMetadataBean.assertionStatement}" />
            </p:column>
            <p:column>
                <p:commandButton rendered="#{item.profileBean.profileLocation == cc.attrs.managedBean.selectedComformanceProfile.name}" value="edit" immediate="true"
                actionListener="#{cc.attrs.managedBean.editDataValueAssertion}" update=":DataValueComposite:DataValueForm">
                </p:commandButton>
            </p:column> 
        </p:dataTable>
    </h:form>

When I remove the immediate=开发者_Go百科true the form is validated and since one of the required field (supposed to be populated) is missing, I got a validation error. This is why I have immediate=true but it should be necessary since all the items in the data table should be valid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号