voyent
partialSubmit doesn't work correctly after failed validation  XML
Forum Index -> General Help
Author Message
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hi there!
Ok, so here is the scenario:
1. I have a Number inputText control (with required=true and Integer validation)
2. I have a checkbox with partialSubmit = true

And now,
1. If I click the checkbox on and off, the submit is made correctly (the required validation on the inputText is avoied) - correctly
2. If I write some garbage in inputText (like "asdfg"), and I play again with the checkbox, validation kicks in ("asdfg" is not a number, after all) - correctly
3. Now I clear the inputText control and play with the checkbox - I get "Required field" for the inputText...

So again, the required validation is done only if I previously entered some wrong data in the field.

This should not be like that, right?

Eduard
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


No anwer to this one?

I started meeting this kind of strange behavior consistently, also when some commandButton get's involved:

Say I have a selectOneMenu partialSubmit-able and a panelStack whose rendered panel depends on the selected value. In one of the panel of the stack there is a required inputText.

Now, everything works ok, until I try to submit the form with this specific panel rendered. When I do that, required validation kicks in (normally), but then this validation kicks in also when I just change the value of the selectOneMenu on this particular panel.
Here is the xhtml code
Code:
 		<ice:selectOneMenu value="#{myController.selectedPanel}" partialSubmit="true" valueChangeListener="#{myController.selectPanel}">
 			<f:selectItem itemValue="preaccepted" itemLabel="Preacepted OK" />
 			<f:selectItem itemValue="resent" itemLabel="Resend to V1" />
 		</ice:selectOneMenu>
 
 		<ice:panelStack selectedPanel="#{myController.selectedPanel}">
 			<ice:panelGrid columns="1" id="preaccepted">
 				<ice:outputText value="Comment: " />
 				<ice:inputTextarea value="#{myController.comment1}" rows="3" cols="60" label="Comment">
 					<f:validateLength maximum="1200"/>
 				</ice:inputTextarea>
 			</ice:panelGrid>
 			<ice:panelGrid columns="1" id="resent">
 				<ice:outputText value="Comment: *" />
 				<ice:inputTextarea value="#{myController.comment2}" rows="3" cols="60" required="true" label="Comment">
 					<f:validateLength maximum="1200"/>
 				</ice:inputTextarea>
 			</ice:panelGrid>
 		</ice:panelStack>
 		<ice:commandButton value="Save answer" action="#{myController.saveAnswer}" />
 
 

in myController.selectPanel I just update the selectedPanel property to the new one and I force renderResponse().

Now a workaround would be to take away the required attribute from the inputTextarea and do the validation by hand ... but hey ... this is not in the spirit of JSF.

Again, the problem in my opinion is that after a failed validation (because of validator or required), the validation kicks in even on partialSubmits.

Eduard
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hmmm .... looks different now ...
Actually the problem is not that the validation kicks in, but the validation messages are saved between 2 partial submits (why only 2?).
After a deeper thinking ... this looks ok, on a form with many fields ... you want the validation messages to be saved and seen even after navigating from one field to the other ... but in my case ... I have a panelStack ... where a panel can get rendered after it was previously unrendered. And still ... the validation messages are saved ... which is not good, at least for me :)...

Eduard.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team