• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

selectOneMenu value not being set on postback

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
John Footh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic