File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes h:selectOneListBox validation trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:selectOneListBox validation trouble" Watch "h:selectOneListBox validation trouble" New topic
Author

h:selectOneListBox validation trouble

Fabrizio Fabrizi
Greenhorn

Joined: Mar 04, 2011
Posts: 1
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

Joined: Jun 29, 2011
Posts: 30
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

Joined: May 15, 2011
Posts: 26
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

Joined: Jun 29, 2011
Posts: 30
Thanks for the reply. In may case the managed bean is already request scoped..
Yahya Arshad
Greenhorn

Joined: May 15, 2011
Posts: 26
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

Joined: Jun 29, 2011
Posts: 30
I tried that solution but still it is not working..
 
 
subject: h:selectOneListBox validation trouble
 
Similar Threads
How to dynamically set panel header on a condition using <f:facet
Using dropDown in jsf
I need help with ajaxSingle, reRender and immediate.
noSuchElementException when using SelectoneMenu
@DataModelSelection always returns the first element