Two Laptop Bag*
The moose likes JSF and the fly likes selectOneMenu value not being set on postback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "selectOneMenu value not being set on postback" Watch "selectOneMenu value not being set on postback" New topic
Author

selectOneMenu value not being set on postback

John Footh
Greenhorn

Joined: Mar 10, 2011
Posts: 4
I have this simple code:



So, when the user changes the amount in the select box, the search executes and displays the chosen rows per page. The problem is, the "itemsPerPage" value always ends up being null. I've tried what seems like a million different things but can't seem to get it to work. I'm guessing it has something to do with the JSF phases which I am not too familiar with. I am about to switch to old school HTML forms. Can anyone offer an explanation as to why this isn't working (and perhaps a solution) ?

Thanks!

-JF

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Welcome to the JavaRanch, John!

You haven't supplied an Action processor for this View. So, yes, you're missing one of the lifecycle components. The <h:form> element doesn't support an "action" attribute, so the attribute you coded is being ignored.

And I'm afraid that JavaScript cannot properly submit the context needed, anyway. There's a lot of stuff going on "under the hood" in JSF, so you really need to be using JSF to manage it.

Although it's always good to keep a real "submit" button on a form, just in case the user has disabled JavaScript, if you want to bind an action processor to a selection onchange event, you'll need some extra help, either with an extended tagset such as RichFaces, or using the AJAX support features added in JSF version 2.


Customer surveys are for companies who didn't pay proper attention to begin with.
John Footh
Greenhorn

Joined: Mar 10, 2011
Posts: 4
Thanks for the advice Tim.

I actually did a lot more research on the JSF lifecycle. Also, I'm using Seam which provides some conveniences for dealing with this.

Ultimately, using Seam, I changed the scope of my search component to PAGE which preserves the parameter through a post back. Then I used a page action (another Seam convenience) which executes code on any page load. These two together allowed me to accomplish my goal.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selectOneMenu value not being set on postback
 
Similar Threads
Problem using valueChangeListener and onchange
Seam/RichFaces - extendedDataTable, datascroller, and changeable page size
JSF - Missing source code using templating and composition
javax.xml.rpc.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException:
can anybody help ??