[JBoss Seam] - Re: My list of questions: Seam validation, transactions and
by hstang
"gavin.king(a)jboss.com" wrote : "hstang" wrote : I played around with JSF validation for a few days, and I just couldn't get it play nicely with Seam. I ran into some bizarre problems with transaction management and I just said forget it--I resorted to just action-validation instead.
| | I don't know why you had problems by "don't use JSF validation" is definitely not great advice for new users....
| That was certainly not my intention but after re-reading what I wrote, I could see how it can be interpreted that way.
|
| My problems *could* be related to what beligum is experiencing as it had to do with transactional errors using JSF validators. I raised JIRA-1408, but I still haven't found a solution yet. I wanted to upload a plain-vanilla test case but can't find an option to upload any more. Instead spending any more time on it, fortunately Seam provides other ways at doing validation so I am not stuck with one particular way of doing things.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052934#4052934
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052934
18Â years, 10Â months
[JBoss Seam] - Re: My list of questions: Seam validation, transactions and
by petemuir
Ok, lets see the backing bean as well :)
You are using a form of JSF validation (#{spaceManager.validateSpaceName}), but you aren't using what Gavin is calling JSF (I would perhaps call it Seam/Hibernate/JSF validation ;) ) - Seam/JSF/Hibernate validation is using a combination of @Min, @Max etc. and s:validate/s:validateAll. This is the simplest and most powerful validation available in Seam IMO.
anonymous wrote : Do I still need <s:validateAll/> in this case?
No.
Doing validation in action methods (in your case #{spaceManager.updateInstance}) is fine, but, it certainly isn't done in the JSF validation phase, so, your model *will* have been updated with invalid data. It's your responsibility as the developer to deal with this (using @Rollback is, IIRC, one way of doing this, another is to be in flushmode=MANUAL and reload the data manually). This is CERTAINLY NOT the recommended way of doing simple validation (but is required for more complicated situations, like when you need to compare values).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052933#4052933
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052933
18Â years, 10Â months
[JBoss Seam] - Re: My list of questions: Seam validation, transactions and
by beligum
Hi Gavin, here's my code without the templates:
| <h:form>
| <table>
| <tr>
| <td><h:outputLabel for="newSpaceName">name</h:outputLabel></td>
| <td>
| <h:inputText
| id="newSpaceName"
| value="#{selectedSpaceInstance.entityData.name}"
| required="true"
| validator="#{spaceManager.validateSpaceName}" />
| </td>
| </tr>
| <tr>
| <td><h:outputLabel for="newSpaceCompany">company</h:outputLabel></td>
| <td>
| <h:selectOneMenu id="newSpaceCompany" value="#{selectedSpaceInstance.entityData.company}" required="true">
| <s:selectItems value="#{companyManager.possibleSpaceCompanies}" var="company" label="#{company.name}" />
| <s:convertEntity />
| </h:selectOneMenu>
| </td>
| </tr>
| <tr>
| <td></td>
| <td>
| <h:commandButton action="#{spaceManager.updateInstance}" value="update" type="submit" />
| </td>
| </tr>
|
| </table>
| </h:form>
|
The action-method #{spaceManager.validateSpaceName} is doing some basic unicity-checking on the space-name, that's all. I really like JSF-validation (I hope this _is_ JSF-validation) over annotations in the entity beans, because of the freedom it gives me to do what I want with the data. (or perhaps I'm just too ignorant regarding annotations, that's possible, too)
Do I still need <s:validateAll/> in this case?
btw, yes, indeed, I check the DB to see if my changes are persisted or not.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052929#4052929
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052929
18Â years, 10Â months