myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Kushwaha <blue...@googlemail.com>
Subject Re: Setting domain object into a managed bean from an input form
Date Thu, 30 Nov 2006 21:54:21 GMT
Okay. The domain object part is working fine now ie when I set the beans 
in the request / session scope.

Sorry for the confusion. Am still wondering why it didnt work on the 1st 
attempt yesterday.

Anyway though, when the bean is put into session scope the behaviour is 
a bit different from when its in
the request scope. The methods on the managed bean seem to get executed 
just once. After that it sort
of gets the components from the session and repaints the view w/o 
executing the method again. Is this
expected?

TIA.

Amit.

Andrew Robinson wrote:
> Request scope works fine as long as you don't expect your managed
> bean's data to be there on the POST back. Reqest means just that, the
> managed bean is created for the life of one request and one request
> only. So in your case, your member variables (domainObject) will be
> null when you POST your form. t:saveState restores values between
> requests by storing variables into the component state and restoring
> them on POST of the form.
>
> On 11/30/06, Amit Kushwaha <bluenex@googlemail.com> wrote:
>> Andrew,
>>
>> Yup, the managed bean was in the session scope.
>>
>> But why wouldn't it work for a request scope? Cos, all managed beans in
>> the application are dealing with domain objects. It would ideal to put
>> some managed beans in just the request scope.
>>
>> TIA.
>>
>> Amit
>>
>>
>> Andrew Robinson wrote:
>> > Sounds like your managedBean's scope is not what you need. Use session
>> > scope, Conversation scope (from 3rd parties) or use t:saveState.
>> >
>> > On 11/30/06, Amit Kushwaha <bluenex@googlemail.com> wrote:
>> >> Hi.
>> >>
>> >> Am trying to set/push in some properties on a domain object in a 
>> managed
>> >> bean from an input form.
>> >>
>> >> So on the input form, I got some fields like this,
>> >>
>> >> <h:inputText id="someProperty"
>> >> value="#{managedBean.domainObject.property}"/>
>> >>
>> >> And in the managed bean and domain object,
>> >>
>> >> class ManagedBean {
>> >>
>> >>   private DomainObject domainObject;
>> >>
>> >>   public ManagedBean() {
>> >>     domainObject = new DomainObject();
>> >>   }
>> >>
>> >>   setters/getters...
>> >>
>> >> }
>> >>
>> >> class DomainObject {
>> >>
>> >>   private String property;
>> >>
>> >>   setters/getters...
>> >>
>> >> }
>> >>
>> >> The property doesn't get set. What is missing?
>> >>
>> >> If the property in the domain object is moved in to the managed 
>> bean and
>> >> the view changed to,
>> >>
>> >> <h:inputText id="someProperty"  value="#{managedBean.property}"/>
>> >>
>> >> It works okay. This is using JSF + JSP.
>> >>
>> >> TIA.
>> >>
>> >> Amit.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>
>


Mime
View raw message