Retrieve value from state on submit

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?

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.

An IDE is no substitute for an Intelligent Developer.

All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad: