-
1. Re: @Unwrap question
rlhr Jul 7, 2007 10:22 AM (in response to ellenzhao)As far as I know, one difference is the way you are going to access your object.
If you use @Factory, you'll have to access it through the bean: #{myBeanName.myMethodName} (any first reference to myBeanName will trigger a call to the factory method)
Using unwrap, you directly use the bean name: #{myBeanName} (the bean and any other methods remain hidden, only the result of the unwrap method is exposed).
There might be other differences, but I'm not aware of them... -
2. Re: @Unwrap question
wschwendt Jul 7, 2007 10:56 AM (in response to ellenzhao)"enzhao" wrote:
Hi folks,
1. What's the difference between @Factory and @Unwrap in the following two code fragments? (from reference section 3.8)
the Factory method gets only called if the referenced context variable, the factory method is defined for, is not yet bound to a value. In your case the context variable is "customerList". Once this context variable is set to a value, the factory won't be called anymore, when "customerList" gets referenced additional times.
In contrast, the method annotated with @unwrap gets called EVERY time the manager component with the name "customerList" is referenced. -
3. Re: @Unwrap question
pmuir Jul 8, 2007 9:25 AM (in response to ellenzhao)@Factory is useful to populate a context variable that is unchanging, or the change originates within your context. within it's scope (for example a list of hotels available to book). @Unwrap is useful if the variable can change outside your control (e.g. from another users conversation)
-
4. Re: @Unwrap question
ellenzhao Jul 8, 2007 7:08 PM (in response to ellenzhao)Thanks to you all! :-)
Regards,
Ellen -
5. Re: @Unwrap question
marius.oancea Oct 15, 2007 1:45 PM (in response to ellenzhao)As I know, @Unwrap annotate methoid is called everytime you access customerList variable. @Factory annotated method gets called only one time (if variable is not yet initialised)
-
6. Re: @Unwrap question
mnrz Oct 16, 2007 8:34 AM (in response to ellenzhao)Hi all
I have a question about @Unwrap.
I tried @Unwrap in a test application and as I understood, the whole bean will play on behalf of the wrapped context variable.
for instance if I have method@name("bean") class MyBean { .... @Unwrap public User getUser(){ } }
the "bean" is referring to an instance of type User, isn't it?
but the thing I want to know is if the values inside a page is changed by the user and press submit button, Are these new changes visible at the server side? for example, the user changes his address which is a property of class User, will this change being applied at context variable inside the MyBean?
thanks