• Post Reply Bookmark Topic Watch Topic
  • New Topic

h:messages problem  RSS feed

 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for the best way to display error messages to the page. I currently have an h:messages that will print out a validation error when someone does not click an item in a selectmanymenu. The error comes up once the command button is pushed, this is how it is suppose to work, simple enough. The problem comes when a user clicks a one of two radio buttons above the manymenu. These radio buttons before a page load and brings up the error when it's not suppose to. I am just not sure if there is an easy way to tie the error message in with the command button only, or a way to say to the messages, only display if the command button is pushed and not the radio buttons..

Any advice is appreciated, thanks for the help
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesse Felter:
The problem comes when a user clicks a one of two radio buttons above the manymenu. These radio buttons before a page load and brings up the error when it's not suppose to.


You must be submitting the page on clicking radio button isn't? Hence JSF is doing all validations.

There can be many work around - but first can you explain what are you trying to do?
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a list box (selectmanymenu) the idea is to have an item selected out of there and have the user click the button for action to be performed. However there are two sets of radio buttons that filter what is in that list box, so if I click on a radio button it will give me a filtered list. These radio buttons when clicked give a submit and new data is posted, this therefore brings up the validation. The validation will only come up if an item in the list box is not selected. I only want the validation to be checked if the command button is pushed, instead of clicking on the radio buttons.

Hopefully this is more clear. Thanks
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you click radio buttons, which server sidemethod do you call ? any ValueChangeListener?
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the jist of the radio buttons

<lth:selectOneRadio id="projectLevel" value="#{ReportBean.level}"on click="document.forms.critForm.submit();"valueChangeListener="#{ReportBean.selectLevel}"immediate="false"><f:selectItems value="#{ProjDocReportBean.projectLevelItems}"/>
</h:selectOneRadio>
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show you selectLevel method.
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void selectLevel(ValueChangeEvent event) throws Exception
{
Integer projectLevelNewValue = (Integer) event.getNewValue();
this.setLevel(projectLevelNewValue);
this.getProjectList();
}
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It should work now?
P.S. will explain the logic if it works
[ April 29, 2005: Message edited by: Varun Khanna ]
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put the changes in, the filtering works but it didn't seem to fix the validation problem. The same issue still happens.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works for me.

Okay, then do one dodgy hack ... when you click radio button, call a javascript function and set the value of your component to empty string i.e. "" and hence the validation wont be called over this component.

or in your valueChange method, set the submittedValue of the component giving validation error to empty string "", hence validations won't happen.

But ideally the earlier approach I suggested should work.
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help.. I'm sure i just need to mess around with it to get it working.. What is the logic behind the code? maybe that will help in debugging why its not working.. Thanks again.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that code, we have setr immediate=true, which means the listner will be called in the "Apply request" phase only and at the end we have done renderResponse which means we are by-passing validation phase. Calling renderResponse() take the life cycle directly to render response phase, hence you validation phase is by-passed and component's aren't validated.

You may like to see this also. Here there was a disucussion over this.
 
Jesse Felter
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhhh.. that makes plenty of sense.. in fact I have it working now with that code.. thanks for all the help
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!