Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get rid of highlighting for invalid components in JSF/Primefaces
    text
    copied!<p>I'm using Primefaces 3.5.2, Mojara 2.1.2. I have a main xhtml page and a dialog in this page. Below is a simple example</p> <pre><code>&lt;h:form&gt; &lt;p:commandButton id="btn1" oncomplete="dlg.show()" update="dlg" process="@form"/&gt; &lt;/h:form&gt; &lt;p:dialog id="dlg" widgetVar="dlg"&gt; &lt;h:form&gt; &lt;p:tabView id="tabview" activeIndex="..always 0 ..."&gt; &lt;p:tab id="tab1"&gt; &lt;p:panelGrid&gt; &lt;p:inputText id="input1" value="#{myBean.integer}"/&gt; p:selectOneMenue is rendered wrong, if the dialog is reopened. &lt;p:selectOneMenu id="select" value="#{myBean.listVal}" filter="true" style="width:100%"&gt; &lt;p:selectItems value="#{myBean.list}" /&gt; &lt;/p:selectOneMenu&gt; &lt;p:commandButton action="#{myBean.ok}" value="ok" oncomplete="..." update="dlg" process="@form"/&gt; &lt;p:commandButton action="#{myBean.cancel}" value="cancel" update="dlg" process="@form"oncomplete="dlg.hide()"/&gt; &lt;p:panelGrid&gt; &lt;/p:tab&gt; &lt;p:tab id="tab2"&gt; ... &lt;/p:tab&gt; &lt;/p:tabView&gt; &lt;/h:form&gt; &lt;/p:dialog&gt; </code></pre> <p>Managed Bean:</p> <pre><code>@ManagedBean @SessionScoped class MyBean { Integer integer; String listVal; public Integer getInteger() { ... } public void setInteger (Integer i) { ... } public void ok() { ... } public void cancel() { ... } public List&lt;SelectItem&gt; getList() { ... } public getListVal () { ... } public setListVal (..) { ... } } </code></pre> <p>If I open the dialog, write in input field (input1) something wrong, e.g. text instead of number, and click "ok", then the input will be invalid and marked as red. I close the dialog with cancel or close button. If I reopen the dialog the input field remains marked as red. I don't want this behaviour.</p> <p>Another problem: in invalidated state "select"-Component from Primefaces changes often the size. If I replace p:selectOneMenu with h:selectOneMenu then the component has the right size. </p> <p>My <strong>question</strong> is how you can change the state of JSF/Primefaces so that the JSF will be in "validate" state after you reopen the dialog and JSF will not show highlighting. </p> <p>I have tried to change the component state with setValid(true) for all components in "myBean.cancel" it does not help however. Similar as in this question <a href="https://stackoverflow.com/questions/14376875/jsf2-primefaces-how-to-highlight-the-inputtext-border-with-red-color">How to mark other components invalid in a custom multi-field validator</a></p> <h2>Update</h2> <p>Thank you, the problem with red borders is disappeared. But I have another one very similar problem. see: <a href="https://stackoverflow.com/questions/16030920/pselectonemenue-changes-size-in-primefaces-jsf-if-converter-validator-error-occ">p:SelectOneMenue changes size in Primefaces/JSF if Converter/Validator error occurs</a></p>
 

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