3 Replies Latest reply on Jul 24, 2007 8:05 AM by shooali

    modalpanel suggestionbox and a4j:repeat

    shooali

      Hi

      I have a page that includes a modalpanel which in it there is a h:table with a4j:repeat on its 's.
      in each there is an inputText with a suggestion box.
      opening the modalPanel once which only has one iteration in it (so there is only one suggestionbox) all works fine. when opening the second time in a different situation which results in two iterations in the modalpanel thus having two suggestion boxes, the first of them, suggest the old values in the popup from the previous modalpanel.
      I have looked in the forum and found out that adding

      <a4j:ajaxListener type="org.ajax4jsf.ajax.ForceRender"/>
      inside the suggestionbox will solve the problem, so I did. and it did. only this created a new problem!!, now when submitting the form in the modal panel, I get an error: "view state couldn't be restored...". searching the forum again, I found post that looks similar which concluded that it was fixed in a4j1.1.1+rich3.0.1.
      well I use the above versions, and it does not help
      if I remove the reRender of some components in the parent page of the modalPanel, which occurs after the form submit, it does not happen.

      attached are some code snippets.

      thanks,

      parent page
       <ui:composition>
       <script language="javascript" >resizeAllLayouts();</script>
       <c:set var="pageBean" value="#{ruleConditionsStageBean}"/>
       <table id="ruleConditionsTable" width="95%" height="40%" border="0">
       <tr>
       <td colspan="2" style="border-right: none">
       <span class="txt_hd">
       #{messages['POLICY.WIZARD.LABEL.RULE.CONDITIONS.DEFINE_CONDITIONS']}
       </span>
       </td>
       </tr>
       <tr>
       <td valign="top" colspan="2" style="border-right: none">
       <div style="border: 1px solid #bfcedf; " id="rule_compliance_constraint">
       <h:panelGroup id="ruleComplianceConstraints">
       <table style="background: #FFFFFF" width="95%">
       <!-- Custom Constraints comes first****************************** -->
       <a4j:repeat var="customConstraint" value="#{pageBean.rule.customComplianceConstraints}">
       <tr>
       <td style="border-right: none">
       <h:selectBooleanCheckbox
       value="#{customConstraint.enabled}">
       <a4j:support event="onclick"
       reRender="rule_summary, desired_state_coverage, ruleComplianceConstraints"/>
       </h:selectBooleanCheckbox>
       </td>
       <td style="border-right: none">
       <h:panelGroup id="nextCustomConstraint" style="color: blue; cursor: pointer;font-weight: bold">
       <h:outputText value="#{customConstraint.sentence.text}"/>
       <a4j:support event="onclick"
       action="#{pageBean.onCustomConstraintClicked}"
       oncomplete="Richfaces.showModalPanel('customConstraintModalPanel',{width:100, top:50})"
       reRender="addCustomConstraintPopup">
       <f:param name="customConstraintId" value="#{customConstraint.webId}"/>
       </a4j:support>
       </h:panelGroup>
       </td>
       </tr>
       </a4j:repeat>
       <a4j:jsFunction name="damdam" id="hole"
       reRender="rule_summary, desired_state_coverage"
       eventsQueue="yhuj"
       requestDelay="150">
       </a4j:jsFunction>
       <a4j:repeat var="constraint" value="#{pageBean.rule.CIFilteredComplianceConstraints}">
       <tr>
       <!-- Constraint checkbox -->
       <td style="border-right: none">
       <h:selectBooleanCheckbox
       value="#{constraint.enabled}">
       <a4j:support
       event="onclick"
       ajaxSingle="true"
       reRender="compliance_def_constraint_sentence_group"
       oncomplete="damdam();"
       />
       </h:selectBooleanCheckbox>
       </td>
       <!-- Constraint text description -->
       <td style="border-right: none">
       <h:panelGroup id="compliance_def_constraint_sentence_group">
       <a4j:repeat var="fragment" value="#{constraint.sentence.fragments}">
       <h:outputText rendered="#{fragment.typeText}" value="#{fragment.text}"/>
       <h:outputText rendered="#{fragment.typeEmptyReference and !constraint.enabled}" value="______"/>
       <h:outputText
       id="fragment_link_empty"
       rendered="#{fragment.typeEmptyReference and constraint.enabled}"
       style="color: blue; cursor: pointer;font-weight: bold;font-style: italic; text-decoration:underline"
       value="#{messages['POLICY.WIZARD.LABEL.RULE.SCOPE.CLICK_HERE']}">
       <a4j:support
       id="onDefComConstClickedOne"
       event="onclick"
       action="#{pageBean.onConstraintClicked}"
       oncomplete="Richfaces.showModalPanel('defConstraintModalPanel',{width:100, top:50})"
       reRender="addDefConstraintPopup">
       <f:param name="editedConstraintWebId" value="#{constraint.webId}"/>
       </a4j:support>
       </h:outputText>
       <h:outputText
       rendered="#{fragment.typeReference and !constraint.enabled}"
       style="font-weight: bold"
       value="#{fragment.text}"/>
       <h:outputText
       id="fragment_link"
       style="color: blue; cursor: pointer;font-weight: bold; text-decoration:underline"
       rendered="#{fragment.typeReference and constraint.enabled}"
       value="#{fragment.text}">
       <a4j:support
       id="onDefComConstClicked2"
       event="onclick"
       action="#{pageBean.onConstraintClicked}"
       oncomplete="Richfaces.showModalPanel('defConstraintModalPanel',{width:100, top:50})"
       reRender="addDefConstraintPopup">
       <f:param name="editedConstraintWebId" value="#{constraint.webId}"/>
       </a4j:support>
       </h:outputText>
       </a4j:repeat>
       </h:panelGroup>
       </td>
      
       </tr>
       </a4j:repeat>
       </table>
       </h:panelGroup>
       </div>
       </td>
       </tr>
       <tr>
       <!-- "Add attribute" button -->
       <td valign="top" rowspan="2">
       <span class="btn_sq_area">
       <span class="btn_sq">
       <a4j:region id="add_custom_constraint_region">
       <a4j:commandLink id="add_attr" action="#{pageBean.onAddAttribute}"
       oncomplete="Richfaces.showModalPanel('customConstraintModalPanel',{width:100, top:50})"
       reRender="addCustomConstraintPopup">
       <span>#{messages['POLICY.WIZARD.STAGE.DESIRED_STATE.ADD_ATTRIBUTE']}</span>
       </a4j:commandLink>
       </a4j:region>
       </span>
       </span>
       </td>
       </tr>
       </table>
      
       <a4j:region id="close_custom_constraint_region">
       <a4j:jsFunction name="closeCustomConstraintModalPanel"
       reRender="ruleComplianceConstraints, rule_summary, desired_state_coverage"
       oncomplete="Richfaces.hideModalPanel('customConstraintModalPanel');">
       </a4j:jsFunction>
       </a4j:region>
       <a4j:region id="close_def_constraint_region">
       <a4j:jsFunction name="closeDefConstraintModalPanel"
       reRender="ruleComplianceConstraints, rule_summary, desired_state_coverage"
       ajaxSingle="true"
       limitToList="true"
       oncomplete="Richfaces.hideModalPanel('defConstraintModalPanel');"
       >
       </a4j:jsFunction>
       </a4j:region>
       <table id="ruleConditionsSummaryTable" width="95%" height="30%" border="0" >
       <tr>
       <td valign="bottom">
       <h:outputText class="summary_panel_header" value="#{messages['POLICY.WIZARD.LABEL.RULE.CONDITIONS.RULE_SUMMARY']}"/>
       </td>
       <td valign="bottom">
       <span class="btn_sq_area">
       <span class="btn_sq">
       <a4j:commandLink id="recalc_rule_cond_btn" oncomplete="resizeAllLayouts();"
       type="submit"
       reRender="desired_state_coverage"
       actionListener="#{pageBean.calculateRuleCoverage}">
       <span>#{messages['POLICY.WIZARD.STAGE.DESIRED_STATE.CALCULATE_COVERAGE']}</span>
       </a4j:commandLink>
       </span>
       </span>
       </td>
       </tr>
       <tr>
       <td valign="top" width="60%" style="border-right: none">
       <fieldset id="rule_summary_fieldset" class="summary_panel_box" style="width:99%;height:99%;padding:6px;">
       <h:panelGroup id="rule_summary">
       <a4j:repeat var="fragment" value="#{pageBean.ruleSummaryFragments}">
       <h:outputText rendered="#{fragment.typeText}" value="#{fragment.text}"/>
       <h:outputText rendered="#{fragment.typeReference}" value="#{fragment.text}" style="font-weight: bold"/>
       <h:outputText rendered="#{fragment.typeEmptyReference}" value="______"/>
       <t:htmlTag rendered="#{fragment.typeSeperator}" value="br"/>
       </a4j:repeat>
       </h:panelGroup>
       </fieldset>
       </td>
       <td valign="top" width="40%" style="border-right: none">
       <fieldset id="rule_coverage" class="summary_panel_box" style="width:99%;height:99%;padding:6px;" >
       <span jsfc="h:outputText" id="desired_state_coverage" value="#{pageBean.ruleCoverageString}" />
       </fieldset>
       </td>
       </tr>
      
       </table>
       </ui:composition>
      
      


      modalPanel content:
       <ui:composition>
       <c:set var="pageBean" value="#{addDefinitionConstraintBean}"/>
       <t:saveState value="#{addDefinitionConstraintBean}"/>
       <script language="javascript">
       function checkDefErrorAndClose()
       {
       // if no error messages found
       if(document.getElementById('defConstraintMPInclude:addDefConstraintForm:err_msgs')==null)
       {
       closeDefConstraintModalPanel();
       }
       }
      
       </script>
       <a4j:outputPanel id="addDefConstraintPopup">
       <h:form id="addDefConstraintForm">
       <div id="updateConstraintAssignmentPopup">
       <!-- A single table where each parameter has several rows -->
       <table id="assignments" cellpadding="2" cellspacing="0" width="50%" style="padding-top: 20px; padding-left: 20px;padding-right: 20px;" border="0">
       <a4j:repeat id="eee" var="assignable" value="#{pageBean.editedConstraint.paramAssignments}">
       <tr>
       <td style="padding-top:20px" valign="top" width="20%" align="right">#{messages['PARAM_ASSGNMENT_PAGE.ATTRIBUTE']}</td>
       <td style="padding-top:20px" valign="top" width="80%"><b>#{assignable.description}</b></td>
       </tr>
       <tr>
       <td align="right">#{messages['PARAM_ASSGNMENT_PAGE.OPERATOR']}</td>
       <td>
       <h:selectOneMenu id="select_operator"
       value="#{assignable.operator}" converter="operatorConverter">
       <f:selectItems value="#{assignable.operatorSelectItems}" />
       </h:selectOneMenu>
       </td>
       </tr>
       <tr>
       <td valign="top" align="right">#{messages['PARAM_ASSGNMENT_PAGE.VALUE']}</td>
       <td valign="top">
       <a4j:region id="param_value_region">
       <h:inputText id="param_value" value="#{assignable.value}"
       validator="#{assignable.validator.validate}"/>
       <h:panelGroup id="param_value_des"
       rendered="#{!assignable.simpleType}">
       <br/>
       #{messages['POLICY.WIZARD.LABEL.AUTOSUGGEST_DESC']}
       </h:panelGroup>
       <rich:suggestionbox
       rendered="#{!assignable.simpleType}"
       selfRendered="true"
       for="param_value"
       var="paramValueSuggestion"
       suggestionAction="#{pageBean.getValueSuggestions}"
       height="200" width="250"
       ajaxSingle="true">
       <f:param name="assignableWebId" value="#{assignable.webId}"/>
       <h:column>
       <h:outputText value="#{paramValueSuggestion}"/>
       </h:column>
       </rich:suggestionbox>
       </a4j:region>
       </td>
       </tr>
       </a4j:repeat>
       </table>
       <table id="constraintEditButtons" cellpadding="10" cellspacing="0" width="100%" style="padding-left: 20px;padding-right: 20px;" border="0">
       <tr valign="bottom">
       <td align="right" colspan="1">
      
       <span jsfc="h:panelGroup">
       <a4j:commandButton
       id="saveUpdateConstraint"
       value="#{messages['GENERAL.BUTTON.OK.LABEL']}"
       action="#{pageBean.saveParamAssignment}"
       oncomplete="checkDefErrorAndClose()"/>
       <a4j:commandButton
       id="cancelUpdateConstraint"
       value="#{messages['CONSTRAINT.CANCEL']}"
       action="#{pageBean.cancelParamAssignment}"
       oncomplete="closeDefConstraintModalPanel()"
       immediate="true"/>
       </span>
       </td>
       </tr>
       <tr>
       <td align="left">
       <a4j:outputPanel id="err_panel" ajaxRendered="true">
       <h:messages id="err_msgs"/>
       </a4j:outputPanel>
       </td>
       </tr>
       </table>
       </div>
       </h:form>
       </a4j:outputPanel>
       </ui:composition>
      


      thanks again