Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

h:selectOneListBox validation trouble

 
Fabrizio Fabrizi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i'm new on this site.
I would present you a strange case.

I've a page with a selectOneListBox, with size="1" and an inputText, both required, and a commandButton.

I do these operations:
- I select a value from listbox
- I leave empty the input text
- I press the command button

The page reload correctly with the required message for input text.

Now, i do this:
- I select the empty option of the listbox
- I leave empty the input text
- I press the command button

The page reload with the required message for both fields, but strangely the select field presents the previous value and not the empty item.


Here the page code


Here the backing bean code:


I'm using JSF 1.2 and the backing bean is a session scoped bean.

So, if i select on page "Module 1" from html select, i get validation error against profile code textfield, correctly. Then i clean module field (html select) and submit again the form. The page reload, i get validation error on both fields correctly, but the html select is not empty, it presents "Module 1" selected!!!

Why?

Doing same trick with input field work correctly.

Any collaboration is appreciated.
 
Deniz Atak
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a similar problem. My problem is the page does not reload with the required message for list box, it just shows the required message for the text input.

My code is:



Do you have any opinion about this problem? Have you found solution to this problem?

Thanks in advance.
 
Yahya Arshad
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am too new in JSF i was having same problem
here is solution which worked for me
go to your confiuration file there you have registered your that managed bean

than see what scope you have set for that managed bean if it is session than replace it with request
because in session scope properties related to your managed bean are stored for all session(means they will be saved till you close window)

but be careful the scope set for whole class not only for a property

<managed-bean>
<managed-bean-class>foo.yourclass</magaged-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>


hope this description enough
 
Deniz Atak
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. In may case the managed bean is already request scoped..
 
Yahya Arshad
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deniz Atak wrote:Hi,

I have a similar problem. My problem is the page does not reload with the required message for list box, it just shows the required message for the text input.

My code is:



Do you have any opinion about this problem? Have you found solution to this problem?

Thanks in advance.


My that solution was for Fabrizio Fabrizi
your solution is this i think
http://www.coderanch.com/t/543537/JSF/java/JSF-Listbox-required-true-field
 
Deniz Atak
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that solution but still it is not working..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic