Is there any way I can validate a jsf input text that is readonly but the value is changed upon some other events triggered?
Answers
From w3:
readonly = "readonly" or "" (empty string) or empty - Specifies that element represents a control whose value is not meant to be edited.
So basically it's the same.
You can use Filter to hide this extension and make your URL SEO friendly. One such implementation of Filter is PrettyFaces.
For example:
If you need http://host:port/yourapp/login
to resolve with your login.xhtml
then in pretty filter configure following way
<url-mapping id="login">
<pattern> /login </pattern>
<view-id> /legacy/user/login.jsf </view-id>
</url-mapping>
Have a look at two min video tutorial
(in order of preference):
style="color: #{yourVar == 'yes' ? 'green' : 'red'};"
- make two
<h:outputText>
components with different styles, each with a differentrendered
attribute (one#{yourVar == 'yes'}
and the other#{yourVar == 'no'}
) - define a (jstl/facelets/jsf 2.0) function that takes the var as argument and returns a style/class -
styleClass="#{my:getStyleClass(yourVar)}"
In addition to kraftan's answer:
By default automatic bean validation in JPA 2.0 works if validation provider is "present in the environment", otherwise it silently doesn't work. You can add
<validation-mode>CALLBACK</validation-mode>
to
persistence.xml
in order to generate an error if validation provider is not found.- JPA doesn't support generation of arbitrary (non-id) properties. Some JPA providers may have extensions.
I have solved this problem with a workaround. I have added an
inputHidden
field that has therequired
attributetrue
that will not appear on the interface, but will be validated:The value of bean.value is changed by other event, and at some reRender on the inputHidden, the validation takes place.