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

commandButton immediate = "true"....  RSS feed

 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I had a problem where, when you clicked a button the page refereshed rather than direct me to some other page.

I went here, realised we had the same problem, so I used 'immediate = "true"' in my <h:commandButton> tag, it did the trick and started forwarding me to the right page, however lacking the data from input fields.

What I want to know is what is the function of the immediate = "true"? does it skip validation/instatiation of the bean and go straight to some page?

Any other information you have on this please let me know.

Thnanks in advance fot your thoughts,
Regards
Zein
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting immediate="true" just skips the validation step, that's why you're redirected without validations. Probably you have a validation error...
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Gabriel.
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a follow up to this, question/problem. Why is it that the logs dont show validation erorrs on JSF?? Is there anyway of getting the errors to be shown, like a jar or something?

Thanks in advance
Zein
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Zein Nunna:
Just a follow up to this, question/problem. Why is it that the logs dont show validation erorrs on JSF?? Is there anyway of getting the errors to be shown, like a jar or something?

Thanks in advance
Zein


Validation errors are meant to be shown in the screen so the user can correct them. (but yes, is kind of disturbing when everything looks ok, but your page is just refreshed instead of redirected)
While working with JSF, I found useful to add a "<h:messages ... >" tag to display all the errors.
 
Tak Ng
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The attribute immediate set to "true" is commonly used when you want to cancel a form. In any other case, you should not activate immediate as it skips validation.
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your reponses so far,

Gabriel, Can you post an example of how you've used <h:message...> to show you validations errors.

I missed <h:column> tags in one of my test pages and the whole thing wouldn't work with no indication of what the error was. Needless to say after hours or trying a billion combinations I hit the jackpot.

In essence this is what my problem is i.e. if I miss a tag or something I want it to say 'Hey you no <h:column> tags found...blah blah'.

Thanks in advance.
Regards
Zein
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the <h:messages> tag will display all the validation errors for the components in the page.
I remember too being in the situation of having a missing tag and nothing working
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!