You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by lmk <lo...@yahoo.fr> on 2007/10/11 09:59:39 UTC

JSF and dependency injection

Hello..

I'd juste understand   how JSF IOC container works..i tried  to do something
like ..

<managed-bean>
  <managed-bean-name>person</managed-bean-name>
  <managed-bean-class>x.y.Person</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>adress</property-name>
   <property-class>x.y.z.Adress</property-class>
   <value>#{adress}</value>
  </managed-property>
 </managed-bean>
 <managed-bean>
  <managed-bean-name>adress</managed-bean-name>
  <managed-bean-class>x.y.z.Adress</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
   <property-name>..</property-name>
   <property-class>...</property-class>
   <value>#{adress}</value>
  </managed-property>
 </managed-bean>

On the Person bean when I set adress value, it's not the same instance of
the adress on the session..I should do #{person.adress.xx} to get adress
values on the jsf pages..
how can i share identical instance for  the bean..???

using annotation and seam we can write on the Person bean:

@In("adress")
	private Adress adress;

thanks ..


-- 
View this message in context: http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151202
Sent from the MyFaces - Users mailing list archive at Nabble.com.


RE: JSF and dependency injection

Posted by "Kito D. Mann" <km...@virtua.com>.
Hmmmm... There really should be only one instance of each (Person and
Address) in the session. Have you tested this to make sure you're not
setting that value somewhere else?

As a side note, it'd probably make more sense to make Address a "none"
scoped object and just access it through the Person object. I think it makes
sense to keep the smallest number of objects in any given scope. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann - Author, JavaServer Faces in Action
http://www.virtua.com - JSF/Java EE consulting, training, and mentoring
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info


> -----Original Message-----
> From: lmk [mailto:lotfi65@yahoo.fr]
> Sent: Thursday, October 11, 2007 3:00 AM
> To: users@myfaces.apache.org
> Subject: JSF and dependency injection
> 
> 
> Hello..
> 
> I'd juste understand   how JSF IOC container works..i tried  to do
> something
> like ..
> 
> <managed-bean>
>   <managed-bean-name>person</managed-bean-name>
>   <managed-bean-class>x.y.Person</managed-bean-class>
>   <managed-bean-scope>session</managed-bean-scope>
>   <managed-property>
>    <property-name>adress</property-name>
>    <property-class>x.y.z.Adress</property-class>
>    <value>#{adress}</value>
>   </managed-property>
>  </managed-bean>
>  <managed-bean>
>   <managed-bean-name>adress</managed-bean-name>
>   <managed-bean-class>x.y.z.Adress</managed-bean-class>
>   <managed-bean-scope>session</managed-bean-scope>
>   <managed-property>
>    <property-name>..</property-name>
>    <property-class>...</property-class>
>    <value>#{adress}</value>
>   </managed-property>
>  </managed-bean>
> 
> On the Person bean when I set adress value, it's not the same instance
> of
> the adress on the session..I should do #{person.adress.xx} to get
> adress
> values on the jsf pages..
> how can i share identical instance for  the bean..???
> 
> using annotation and seam we can write on the Person bean:
> 
> @In("adress")
> 	private Adress adress;
> 
> thanks ..
> 
> 
> --
> View this message in context: http://www.nabble.com/JSF-and-dependency-
> injection-tf4605688.html#a13151202
> Sent from the MyFaces - Users mailing list archive at Nabble.com.


valueChangeListner of selectOneMenu is called three times.....

Posted by Arvind Pandey <ar...@datamatics.com>.

Hi all,

          valueChangeListner of selectOneMenu is called three times.....what
could be the region?
Can any one pls explain why? Is it normal behaviour of selectoneMenu
valueChangeListner?

please help me...
thanks and regards...
Arvind

Disclaimer: The information contained in this e-mail and attachments if any are privileged and confidential and are intended for the individual(s) or entity(ies) named in this e-mail. If the reader or recipient is not the intended recipient, or employee or agent responsible for delivering to the intended recipient, you are hereby notified that dissemination, distribution or copying of this communication or attachments thereof is strictly prohibited. IF YOU RECEIVE this communication in error, please immediately notify the sender and return the original message.

JSF and OpenCMS Integration

Posted by Rodrigo Olmo <ro...@tecnalis.com>.
Hi all, is it posible to integrate OpenCMS with a JSF imlpementation. If so,
how can I do it?

Thanks in advance,

Rodrigo


Re: JSF and dependency injection

Posted by lmk <lo...@yahoo.fr>.
hii

I dont use seam for this project..

I tested sessionScope,on the debug mode, the adress bean values are not nul;
but, on the JSF page the EL expression #{adress.xxxx}, do not display
anything. it seems that it's not the same instance of bean..



Ulath wrote:
> 
> could you try to add sessionScope.address ?
> 
> <managed-bean>
>    <managed-bean-name>person</managed-bean-name>
>    <managed-bean-class>x.y.Person</managed-bean-class>
>   <managed-bean-scope>session</managed-bean-scope>
>    <managed-property>
> <property-name>adress</property-name>
>   <property-class>x.y.z.Adress</property-class>
>   <value>#{sessionScope.adress}</value>
>    </managed-property>
>  </managed-bean>
> 
> and if you use seam why do u need bean definitions in faces-config.xml
> like
> this?
> 
> 
> On 10/11/07, lmk <lo...@yahoo.fr> wrote:
>>
>>
>> No it's not a singleton,
>> adress bean is a session bean, and I need to use it one the person
>> bean..I
>> should have one instance of per session.
>> the purpose here is to set adress bean properties  on the person bean
>> ..using dependency injection..
>> JSF is an ioC container..so its not necessary to use spring just for that
>> !!!
>>
>>
>>
>> logancillo wrote:
>> >
>> > I am thinking about understanding that what you need is that the bean
>> > person
>> > is a singleton. I believe you need spring with jsf.
>> >
>> > 2007/10/11, lmk <lo...@yahoo.fr>:
>> >>
>> >>
>> >> Hello..
>> >>
>> >> I'd juste understand   how JSF IOC container works..i tried  to do
>> >> something
>> >> like ..
>> >>
>> >> <managed-bean>
>> >>   <managed-bean-name>person</managed-bean-name>
>> >>   <managed-bean-class>x.y.Person</managed-bean-class>
>> >>   <managed-bean-scope>session</managed-bean-scope>
>> >>   <managed-property>
>> >>    <property-name>adress</property-name>
>> >>    <property-class>x.y.z.Adress</property-class>
>> >>    <value>#{adress}</value>
>> >>   </managed-property>
>> >> </managed-bean>
>> >> <managed-bean>
>> >>   <managed-bean-name>adress</managed-bean-name>
>> >>   <managed-bean-class>x.y.z.Adress</managed-bean-class>
>> >>   <managed-bean-scope>session</managed-bean-scope>
>> >>   <managed-property>
>> >>    <property-name>..</property-name>
>> >>    <property-class>...</property-class>
>> >>    <value>#{adress}</value>
>> >>   </managed-property>
>> >> </managed-bean>
>> >>
>> >> On the Person bean when I set adress value, it's not the same instance
>> of
>> >> the adress on the session..I should do #{person.adress.xx} to get
>> adress
>> >> values on the jsf pages..
>> >> how can i share identical instance for  the bean..???
>> >>
>> >> using annotation and seam we can write on the Person bean:
>> >>
>> >> @In("adress")
>> >>         private Adress adress;
>> >>
>> >> thanks ..
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151202
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Alonso Isidoro Roman.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151716
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Murat HAZER
> http://www.projedunyasi.org
> 
> 

-- 
View this message in context: http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13209649
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: JSF and dependency injection

Posted by "Ulath (AKA: Murat HAZER)" <mu...@gmail.com>.
could you try to add sessionScope.address ?

<managed-bean>
   <managed-bean-name>person</managed-bean-name>
   <managed-bean-class>x.y.Person</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
   <managed-property>
<property-name>adress</property-name>
  <property-class>x.y.z.Adress</property-class>
  <value>#{sessionScope.adress}</value>
   </managed-property>
 </managed-bean>

and if you use seam why do u need bean definitions in faces-config.xml like
this?


On 10/11/07, lmk <lo...@yahoo.fr> wrote:
>
>
> No it's not a singleton,
> adress bean is a session bean, and I need to use it one the person bean..I
> should have one instance of per session.
> the purpose here is to set adress bean properties  on the person bean
> ..using dependency injection..
> JSF is an ioC container..so its not necessary to use spring just for that
> !!!
>
>
>
> logancillo wrote:
> >
> > I am thinking about understanding that what you need is that the bean
> > person
> > is a singleton. I believe you need spring with jsf.
> >
> > 2007/10/11, lmk <lo...@yahoo.fr>:
> >>
> >>
> >> Hello..
> >>
> >> I'd juste understand   how JSF IOC container works..i tried  to do
> >> something
> >> like ..
> >>
> >> <managed-bean>
> >>   <managed-bean-name>person</managed-bean-name>
> >>   <managed-bean-class>x.y.Person</managed-bean-class>
> >>   <managed-bean-scope>session</managed-bean-scope>
> >>   <managed-property>
> >>    <property-name>adress</property-name>
> >>    <property-class>x.y.z.Adress</property-class>
> >>    <value>#{adress}</value>
> >>   </managed-property>
> >> </managed-bean>
> >> <managed-bean>
> >>   <managed-bean-name>adress</managed-bean-name>
> >>   <managed-bean-class>x.y.z.Adress</managed-bean-class>
> >>   <managed-bean-scope>session</managed-bean-scope>
> >>   <managed-property>
> >>    <property-name>..</property-name>
> >>    <property-class>...</property-class>
> >>    <value>#{adress}</value>
> >>   </managed-property>
> >> </managed-bean>
> >>
> >> On the Person bean when I set adress value, it's not the same instance
> of
> >> the adress on the session..I should do #{person.adress.xx} to get
> adress
> >> values on the jsf pages..
> >> how can i share identical instance for  the bean..???
> >>
> >> using annotation and seam we can write on the Person bean:
> >>
> >> @In("adress")
> >>         private Adress adress;
> >>
> >> thanks ..
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151202
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Alonso Isidoro Roman.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151716
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Murat HAZER
http://www.projedunyasi.org

Re: JSF and dependency injection

Posted by lmk <lo...@yahoo.fr>.
No it's not a singleton,
adress bean is a session bean, and I need to use it one the person bean..I
should have one instance of per session.
the purpose here is to set adress bean properties  on the person bean
..using dependency injection..
JSF is an ioC container..so its not necessary to use spring just for that
!!!



logancillo wrote:
> 
> I am thinking about understanding that what you need is that the bean
> person
> is a singleton. I believe you need spring with jsf.
> 
> 2007/10/11, lmk <lo...@yahoo.fr>:
>>
>>
>> Hello..
>>
>> I'd juste understand   how JSF IOC container works..i tried  to do
>> something
>> like ..
>>
>> <managed-bean>
>>   <managed-bean-name>person</managed-bean-name>
>>   <managed-bean-class>x.y.Person</managed-bean-class>
>>   <managed-bean-scope>session</managed-bean-scope>
>>   <managed-property>
>>    <property-name>adress</property-name>
>>    <property-class>x.y.z.Adress</property-class>
>>    <value>#{adress}</value>
>>   </managed-property>
>> </managed-bean>
>> <managed-bean>
>>   <managed-bean-name>adress</managed-bean-name>
>>   <managed-bean-class>x.y.z.Adress</managed-bean-class>
>>   <managed-bean-scope>session</managed-bean-scope>
>>   <managed-property>
>>    <property-name>..</property-name>
>>    <property-class>...</property-class>
>>    <value>#{adress}</value>
>>   </managed-property>
>> </managed-bean>
>>
>> On the Person bean when I set adress value, it's not the same instance of
>> the adress on the session..I should do #{person.adress.xx} to get adress
>> values on the jsf pages..
>> how can i share identical instance for  the bean..???
>>
>> using annotation and seam we can write on the Person bean:
>>
>> @In("adress")
>>         private Adress adress;
>>
>> thanks ..
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151202
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Alonso Isidoro Roman.
> 
> 

-- 
View this message in context: http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151716
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: JSF and dependency injection

Posted by Alonso Isidoro Roman <al...@gmail.com>.
I am thinking about understanding that what you need is that the bean person
is a singleton. I believe you need spring with jsf.

2007/10/11, lmk <lo...@yahoo.fr>:
>
>
> Hello..
>
> I'd juste understand   how JSF IOC container works..i tried  to do
> something
> like ..
>
> <managed-bean>
>   <managed-bean-name>person</managed-bean-name>
>   <managed-bean-class>x.y.Person</managed-bean-class>
>   <managed-bean-scope>session</managed-bean-scope>
>   <managed-property>
>    <property-name>adress</property-name>
>    <property-class>x.y.z.Adress</property-class>
>    <value>#{adress}</value>
>   </managed-property>
> </managed-bean>
> <managed-bean>
>   <managed-bean-name>adress</managed-bean-name>
>   <managed-bean-class>x.y.z.Adress</managed-bean-class>
>   <managed-bean-scope>session</managed-bean-scope>
>   <managed-property>
>    <property-name>..</property-name>
>    <property-class>...</property-class>
>    <value>#{adress}</value>
>   </managed-property>
> </managed-bean>
>
> On the Person bean when I set adress value, it's not the same instance of
> the adress on the session..I should do #{person.adress.xx} to get adress
> values on the jsf pages..
> how can i share identical instance for  the bean..???
>
> using annotation and seam we can write on the Person bean:
>
> @In("adress")
>         private Adress adress;
>
> thanks ..
>
>
> --
> View this message in context:
> http://www.nabble.com/JSF-and-dependency-injection-tf4605688.html#a13151202
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Alonso Isidoro Roman.