1

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=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.

Sydney
  • 11,964
  • 19
  • 90
  • 142
  • When you say "dialog", do you actually mean ``? Further, it's hard to naildown the cause based on the as far provided information. You'll really have to show a bit more code than that. Show the smallest possible snippet of the `` and the `` which exhibits the problem. – BalusC Aug 05 '11 at 20:04
  • Updated my questions with code sample – Sydney Aug 05 '11 at 20:38
  • I'm not sure, but since you're talking about refilling the fields by ajax after validation errors, you might find this useful: http://stackoverflow.com/questions/6642242/how-can-i-populate-a-text-field-using-primefaces-ajax-after-validation-errors-occ – BalusC Aug 05 '11 at 20:40
  • Is #{item#} really an item (row) from a data table and session scoped? If so, that can only end in tears I'm afraid. – Mike Braun Aug 08 '11 at 08:56
  • The link from `BalusC` seems to fix the problem. – Sydney Aug 08 '11 at 14:10

0 Answers0