Hi,
I'm trying to add model validation to invalidate a transition in the webflow; however, it seems that it always passes validation and completes the transaction even when it shouldn't. I've had this working similarly in older projects (using 2.0.3, I'm currently trying it in 2.0.8)
Here's the important parts of the code:
my flow xml:
my transition trigger button a save button in viewUsers.xhtmlCode:<flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> <secured attributes="ROLE_USER" /> <var name="viewUsers" class="com.nid.um.webflows.ViewUsers"/> <view-state id="viewUsers" view="viewUsers.xhtml" model="viewUsers"> <on-entry> <evaluate expression="viewUsers.updateUsers()" /> </on-entry> <transition on="edit" to="editUser" bind="true" validate="true"/> </view-state> <end-state id="editUser"> <on-entry> <evaluate expression="viewUsers.commit()"/> </on-entry> </end-state> </flow>
(view users has a modal in it with a dialog for editing user info, which i wish to validate. We're also using richfaces here.)
Code:<a4j:commandButton value="#{uim.button_save}" rendered="#{viewUsers.editModal}" action="edit" reRender="table" />
and this simple version of my model bean "ViewUsers" validation function:
(I've removed all real boolean checks because I'd like to see this work first.)
I noticed that the webflow documentation has changed to use a validationContext; but I also noticed that the return type is now void. So how does spring determine if it fails my validation? Is it by the presence of an Error Message in the MessageContext? If so, I have also tried assigning a message to the context and it continues to proceed, as if my validation passes.Code:public boolean validateViewUsers(MessageContext context) { log.debug("Validating the modification of a user, after the save button is pressed."); return false; }
I know it completes the transaction instead of rolling back because the commit function in my end-state wrote a log after my validation function wrote a log.
I'd like to maintain model validation instead of creating a custom validator, because the validation here is very specific, and the way we've organized this in the past has been very clean.
Any insight as to how this works is much appreciated,
Thanks


Reply With Quote
