Viewed   215 times

Is there any way I can validate a jsf input text that is readonly but the value is changed upon some other events triggered?



I have solved this problem with a workaround. I have added an inputHidden field that has the required attribute true that will not appear on the interface, but will be validated:

<h:inputHidden value="#{bean.value}" required="true"
                    requiredMessage="Data must be entered" />

The value of bean.value is changed by other event, and at some reRender on the inputHidden, the validation takes place.

Monday, December 19, 2022

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.

Friday, October 14, 2022

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>

Have a look at two min video tutorial

Friday, September 16, 2022

(in order of preference):

  • style="color: #{yourVar == 'yes' ? 'green' : 'red'};"
  • make two <h:outputText> components with different styles, each with a different rendered 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)}"
Wednesday, November 30, 2022

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


    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.
Monday, August 1, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :