Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF : facing problem with <hx:validateConstraint> and multi-select boxes  RSS feed

gane hiva
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys, I am a JSF newbie, need help.

I have a jsp page, in which I've got a text box and 2 multi-select boxes( using these i am moving items from left select box to right ) and submit button. For text box, I am adding validation like it should take ONLY digits(for example) using <hx:validateConstraint>.

Now my issue is, I would select some items from Left select box and move it to Right select box, and now enter some string("abcef") in text box and hit Submit button, hence validation fails. In this case, whatever items I have moved to Right select box from Left box disappears and go back to the left back. ( I see Page is reloading after submitting).

I want whenever validation fails, it should show an error msg, and the items I have moved to Right Select Box from Left Select Box should be present at the Right Select Box eventhough validation fails.

Can somebody please help me solving this?

I am using JSF 1.2( it is the requirement). below is my text box code.

<h:panelGrid columns="3" cellpadding="2">
<h:outputText styleClass="outputText" value="#{BossMain.common_label_group_name}" />
<h:inputText styleClass="inputText" id="i2" label="#{BossMain.common_label_group_name}" value="#{sessionScope.groupName}" style="width: 150px">
regex="^[ A-Za-z0-9_\u0023\u005F\u002D\u0028\u0029\u0040\u0020]+" />
<f:validateLength maximum="40" />
<h:message styleClass="message" for="i2" />

Tim Holloway
Posts: 18709
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing you should do if JSF 1.2 is a requirement is update your CV and look for another job. JSF 1.2 has been obsolete for several years now. Long enough that any company with any intention towards reliable or secure software should have modernised the app or at least be modernising it now that the app is undergoing maintenance. Please say it's maintenance - there's no excuse for writing new apps in JSF 1.2.

Beyond that, you cannot define "behaviours" on JSF validation. Validation is done by JSF before your application code is entered (exception custom validators, but they shouldn't be manipulating the UI).

JSF validation is a binary process. If a validator likes the data presented to it, it lets it pass. If not, the validator throws an Exception that JSF picks up, extracts the validation error message from, adds the message to its message object, bypasses the update and action phases of the JSF lifecyle and re-renders the page, displaying the error message in whatever way the page template defined for them. It re-renders the offending input controls exactly as it found them, bad data included.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!