Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to have a form with validation and to use rich:modalPanel for data entry too?
    text
    copied!<p>Richfaces 3.3.3, Jsf 1.2:</p> <p>I have a <code>a4j:form</code> that uses some simple validation, mainly <code>required="true"</code> to ensure the form does not get submitted without some necessary data.</p> <p>I also have some complex data to add (optionally) to the form, so I thought the best way to do this is to have a <code>a4j:commandButton</code> that displays a <code>rich:modalPanel</code> where the user can create the complex data set.</p> <p>The created data is also displayed in a <code>h:selectManyListbox</code> that is reRendered when the modalPanel is closed.</p> <p>That's the plan, at least. I have the following problems:</p> <ul> <li>reRender works, but only if I prevent validation via <code>immediate="true"</code> - which in turn seems to prevent the selected data from the modalPanel to be present in the backing Bean</li> <li>if I remove the immediate tag, the data gets updated, but only if there are no validation errors</li> </ul> <p>What is the best way to get this to work the way I want? Is there another, better way?</p> <p><strong>UPDATE:</strong></p> <p>The Validation that fails is in some different part of the form, not in the data entered via the modalPanel, which is displayed in the Listbox</p> <p><strong>CODE:</strong></p> <p>modalPanel:</p> <pre><code>&lt;rich:modalPanel id="addTrimming" domElementAttachment="parent" width="150" height="130"&gt; &lt;f:facet name="header"&gt; &lt;h:panelGroup&gt; &lt;h:outputText value="Define Filter" /&gt; &lt;/h:panelGroup&gt; &lt;/f:facet&gt; &lt;f:facet name="controls"&gt; &lt;h:panelGroup&gt; &lt;h:graphicImage value="/images/close.gif" styleClass="hidelink" id="hidelinkAddTrimming"/&gt; &lt;rich:componentControl for="addTrimming" attachTo="hidelinkAddTrimming" operation="hide" event="onclick"/&gt; &lt;/h:panelGroup&gt; &lt;/f:facet&gt; &lt;h:panelGrid id="trimsettings" columns="3"&gt; &lt;h:outputText value="Target:" style="font-weight:bold"/&gt; &lt;h:inputText id="target" label="XML Filename" required="true" value="#{xmlCreator.trimTarget}"&gt; &lt;/h:inputText&gt; &lt;h:outputText value=""/&gt; &lt;h:outputText value="Mode:"/&gt; &lt;h:selectOneMenu value="#{xmlCreator.trimMode}"&gt; &lt;f:selectItem itemLabel="Quality" itemValue="quality"/&gt; &lt;f:selectItem itemLabel="after Primer" itemValue="afterPrimer"/&gt; &lt;f:selectItem itemLabel="fixed" itemValue="fixed"/&gt; &lt;f:selectItem itemLabel="Median length" itemValue="median"/&gt; &lt;f:selectItem itemLabel="Motif" itemValue="motif"/&gt; &lt;/h:selectOneMenu&gt; &lt;h:outputText value=""/&gt; &lt;/h:panelGrid&gt; &lt;h:panelGroup&gt; &lt;a4j:commandButton value="OK" action="#{xmlCreator.createTrimming}" onclick="from:submit()"&gt; &lt;a4j:support event="oncomplete" ajaxSingle="true" immediate="true" reRender="trimsPanel"/&gt; &lt;/a4j:commandButton&gt; &lt;/h:panelGroup&gt; &lt;/rich:modalPanel&gt; </code></pre> <p>relevant form part:</p> <pre><code>&lt;h:outputText value="Trimming:"/&gt; &lt;a4j:outputPanel id="trimsPanel"&gt; &lt;h:selectManyListbox id="trims" value="#{xmlCreator.selectedTrimmings}"&gt; &lt;f:selectItems value="#{si:toSelectTrimmingList(xmlCreator.trimmings)}"/&gt; &lt;/h:selectManyListbox&gt; &lt;/a4j:outputPanel&gt; &lt;a4j:commandButton id="addTrimButton" immediate="true" value=" + Trimming"&gt; &lt;rich:componentControl for="addTrimming" attachTo="addTrimButton" operation="show" event="onclick"/&gt; &lt;/a4j:commandButton&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload