-
1. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 12, 2010 6:59 AM (in response to benma)1 of 1 people found this helpfulplease check out working sample (full sources in svn)
and that problem description
-
2. Re: modalPanel strange behaviour when validating
benma Nov 16, 2010 5:54 AM (in response to ilya_shaikovsky)Thanks Ilya but that didn't work:
The a4j:region solution skips the validation.
The binding solution ignores a4j:keepAlive which I also need.
The example you gave me a link to doesn't fit me, because they don't use a validator, but make "validation" in the store method when the store button is clicked. (I want to show a validation message next to a specific component and not a global message).
-
3. Re: modalPanel strange behaviour when validating
benma Nov 17, 2010 4:40 AM (in response to benma)Eventually i decided no to use JSF validation, but did my own checking when the "save" button is pressed, and eluded the problem.
It's weird that you can't do a proper validation when staying in the same page (and having a table of choices).
-
4. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 17, 2010 6:00 AM (in response to benma)The a4j:region solution skips the validation.
Not sure get the problem. region at demo used only around the edit control and not affects modal panel validation.
The example you gave me a link to doesn't fit me, because they don't use a validator, but make "validation" in the store method when the store button is clicked. (I want to show a validation message next to a specific component and not a global message).
At first store method contains no validation at all.
public void store() { allCars.set(currentRow, currentItem); keys.clear(); keys.add(currentRow); }
just standard JSF validators makes work. and any custom could be added.
And global message could be replaced with local to component without problems.
-
5. Re: modalPanel strange behaviour when validating
benma Nov 17, 2010 6:21 AM (in response to ilya_shaikovsky)Where's the standard JSF validation in the example code?
Do you mean when there's a type mismatch and an exception is being thrown?
<rich:modalPanel id="editPanel" autosized="true" width="450">
<f:facet name="header">
<h:outputText value="Edit Current Car" />
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/images/modal/close.png" id="hidelink"
styleClass="hidelink" />
<rich:componentControl for="editPanel" attachTo="hidelink"
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
<h:form>
<rich:messages style="color:red;"></rich:messages>
<h:panelGrid columns="1">
<a4j:outputPanel ajaxRendered="true">
<h:panelGrid columns="2">
<h:outputText value="Make" />
<h:inputText value="#{dataTableScrollerBean.currentItem.make}" />
<h:outputText value="Model" />
<h:inputText value="#{dataTableScrollerBean.currentItem.model}" />
<h:outputText value="Price" />
<h:inputText value="#{dataTableScrollerBean.currentItem.price}"
label="Price" immediate="true" />
</h:panelGrid>
<rich:message showSummary="true" showDetail="false" for="price" />
</a4j:outputPanel>
<a4j:commandButton value="Store"
action="#{dataTableScrollerBean.store}"
reRender="make, model, price"
oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
</h:panelGrid>
</h:form>
</rich:modalPanel>Ilya Shaikovsky wrote:
The a4j:region solution skips the validation.
Not sure get the problem. region at demo used only around the edit control and not affects modal panel validation.
The region i'm talking about is from the example you gave me a link to:
<h:outputText value="Enter credit card number:"/>
<h:inputText value="#{data.creditCard}"/>
<h:outputText value="Or use your pre-defined credit card:"/>
<a4j:region>
<a4j:commandLink immediate="true" action="#{data.useMyCreditCard}" reRender="..." value="#{data.myCreditCardName}"/>
</a4j:region>
<h:outputText value="Your entered credit card number:"/>
<h:outputText value="#{data.creditCard}" styleClass="output"/>and this skips the validation.
-
6. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 17, 2010 6:25 AM (in response to benma)1) JSF tries to convert the price to numerical value and f failed - adds message
2) sorry main sample which I wanted to show - "working sample" it uses the similar scenario - modal for editing.
-
7. Re: modalPanel strange behaviour when validating
benma Nov 17, 2010 6:37 AM (in response to ilya_shaikovsky)The thing is when in the same scenario i add my own validator or even required="true" i get the problem i mentioned above.
-
8. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 17, 2010 10:31 AM (in response to benma)1 of 1 people found this helpfulso I'm proposing to check our sources and see where the changes which affects that behavior.
-
9. Re: modalPanel strange behaviour when validating
benma Nov 21, 2010 10:03 AM (in response to ilya_shaikovsky)OK, i did just that, and found out that you need to mark immediate="true" on each component that is being validated, and then it works!
BUT!
If on the demo project i put immediate="true" on another input, i.e.
<h:inputText value="#{dataTableScrollerBean.currentItem.model}" immediate="true"/>
what i get is that if a validation doesn't pass and i press on the X button of the modelPanel and choose another row from the table,
all fields are being refreshed with correct data EXCEPT the second field (i.e. the above field) that i marked with immediate="true".
This happens to all additional fields marked with immediate="true".
And this i checked on the sources of the demo in the link you gave me above!
Please check this, to see i'm correct.
-
10. Re: modalPanel strange behaviour when validating
benma Nov 23, 2010 3:20 AM (in response to benma)Any suggestions for solution?
-
11. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 24, 2010 9:59 AM (in response to benma)doh.. that will not works with more than one input.. seems weird workaround at sample and need to remove when will migrate to 4.x. if at least one new component value will be applyed before validation fail - it will not be updated on next show. So seems the only complete solution at blog to which I already pointed you http://livedemo.exadel.com/richfaces-local-value-demo/ - demo from that blog. with cleaning the value on UIComponent instance.
-
12. Re: modalPanel strange behaviour when validating
benma Nov 24, 2010 10:54 AM (in response to ilya_shaikovsky)Several problems with this solution:
First - what if i have 20 inputs? Go and clean all 20 UIComponents?
Second - for some reason, when i bind an input to the bean, <a4j:keepAlive> on that bean stops working.
-
13. Re: modalPanel strange behaviour when validating
ilya_shaikovsky Nov 24, 2010 11:00 AM (in response to benma)1) just pass some "cleaning" flag and for example wrapper component id(e.g. form around inputs) and simply remove it from JSF tree in your listener. Or for example use the same "store" control actionListener. In the end when changes stored - get UIComponent instance from event iterate parents till find the form - and remove it from tree.
2) bindings should not leave longer than request. if you will made 1) you will not need them at all.