This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Retrieve value from state on submit  RSS feed

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a xhtml with:

... and in the backingbean:

.. and I call a webservice in createNew()

My problem is that maybe I have misunderstood everything about hos JSF works?

I thought that when I used value="#{myListBacking.myState.text} that would bind the xhtml view together with the backing view so that when I click submit, I can retrieve the value from myState and use it for calling the webservice.
I have another field that it works with - but is this even the right way to go?

Posts: 20562
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Peter!

I am not 100% certain I understood the question, but I think you're saying that you can neither see the value of myListBacking.myState.text when you display the View nor can you update the value of myListBacking.myState.text when you submit the form.

Since your examples are only partial, I'm going to have to assume things about the parts that aren't shown. We prefer, when possible, that you show as complete an example as you can (although if you dump large chunks of code, no one will read them, so there's a compromise there).

First off, you don't show "inputfield" actually in a form on your View Template (xhtml). All controls that you want to submit to the server must be in a form, That is basic HTML requirements. For JSF, the form must be a JSF "h:form" tag and not a basic (non-JSF) HTML form tag.

Secondly, you do not show any public get/set methods for the backing bean property "myState". The Expression Language (EL) processor cannot look at or in properties. Instead, you must provide public accessor methods (getMyState(), setMyState()) for it to call.

More precisely, you'd need a "public MyState getMyState() { return myState; }" method. You don't need a "set" method, since this property won't be set from incoming JSF form submit.

Of course, the value "text" within class MyState needs public getText() and setText() methods, because here again EL expects standard JavaBean architecture.
The City calls upon her steadfast protectors. Now for a tiny ad:
global solutions you can do in your home or backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!