-
1. Re: How to validate 4 properties REQUIRED on Update and 5 on Regiter? (newbie from WW to Seam)
mail.micke Aug 15, 2008 10:05 AM (in response to icetbr)Hi
To make sure something is
required
you should use therequired
attribute which is available for all input elements.Example:
<h:inputText value="#{backingBean.property}" required="true"/>The value inside the required attribute can be an EL expression, so if you load your XML files required and editable settings into an application scoped backing bean (if it is same for all users, otherwise session scope) you could do something like this:
<h:inputText value="#{backingBean.reqProperty}" required="#{requiredManager.isRequired('reqProperty')}"/>Which would call a boolean isReqProperty(String propertyName) method on you backing bean. This would be overkill if this setting is static, but perhaps useful if it is dynamic.
Note: passing parameters to methods in EL expressions is something which works in Seam but not in standard JSF.
Hope this helps a bit,
Micke -
2. Re: How to validate 4 properties REQUIRED on Update and 5 on Regiter? (newbie from WW to Seam)
icetbr Aug 15, 2008 3:23 PM (in response to icetbr)Thanks for the answer. I forgot to mention though that I would like to use the Hibernate Validator approach (@NotNull, s:validateAll, ClassValidator.getInvalidValues...).
Also, the
required
part I understood, but what about theforbidden
? For example, if a user is editing his profile, and he can see his username, but not change it, he could HTTP temper the request to alter his username. What part of JSF/Seam prevents this? -
3. Re: How to validate 4 properties REQUIRED on Update and 5 on Regiter? (newbie from WW to Seam)
mail.micke Aug 16, 2008 8:12 PM (in response to icetbr)Can't help you with the hibernate validators.
About the read-only input text, try the normal readonly attribute which should work. I would probably simply use an outputText instead though.
Something like this:
<h:inputText value="#{backingBean.username}" rendered="#{backingBean.username ne user.username}"/> <h:outputText value="#{backingBean.username}" rendered="#{backingBean.username eq user.username}"/>
using some EL to determine if input or output text should be displayed
- micke