You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by daniel ccss <da...@gmail.com> on 2008/01/07 21:24:11 UTC

Call a backing bean before show a JSP

Hi all,

In struts:
I can call a JSP page like http://..../JSP/Example.jsp and I also can call
an action that do something and then do the forward to the Example.jsp like
this: http:// .../Example*.do
*
In JSF:
I can call a JSP page like http://...faces/JSP/Example.jsp *but *there is a
way to call a backing bean before show the JSP?

I need to do something in the backing bean (set some variables, etc) before
showing the jsp, but I dont know if this is posible in JSF.

thanks

Re: Call a backing bean before show a JSP

Posted by Andrew Robinson <an...@gmail.com>.
http://wiki.apache.org/myfaces/Execute_action_on_page_load

On Jan 7, 2008 1:24 PM, daniel ccss <da...@gmail.com> wrote:

> Hi all,
>
> In struts:
> I can call a JSP page like http://..../JSP/Example.jsp and I also can call
> an action that do something and then do the forward to the Example.jsplike this: http:// .../Example
> *.do
> *
> In JSF:
> I can call a JSP page like http://...faces/JSP/Example.jsp *but *there is
> a way to call a backing bean before show the JSP?
>
> I need to do something in the backing bean (set some variables, etc)
> before showing the jsp, but I dont know if this is posible in JSF.
>
> thanks
>

Re: Call a backing bean before show a JSP

Posted by Volker Weber <v....@inexso.de>.
Hi Daniel,

its simple, you need to render a faces response for a non faces request:
use the NonFacesRequestServlet :

http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls#head-6c1aaf488d48f938896da962aaa4361ec3ffaf70

this Servlet implements the needed steps (jsf-1.1-spec 2.1.1).


Regards,
    Volker

2008/1/7, daniel ccss <da...@gmail.com>:
>
>
> Hi all,
>
> In struts:
> I can call a JSP page like http://..../JSP/Example.jsp and I also can call
> an action that do something and then do the forward to the Example.jsp like
> this: http:// .../Example.do
>
> In JSF:
> I can call a JSP page like http://...faces/JSP/Example.jsp but there is a
> way to call a backing bean before show the JSP?
>
> I need to do something in the backing bean (set some variables, etc) before
> showing the jsp, but I dont know if this is posible in JSF.
>
> thanks


-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
All works great know thanks Andrew!!!!

On Jan 8, 2008 10:42 PM, daniel ccss <da...@gmail.com> wrote:

> Andrew this new jar depends of the class: SAXReader?? I recived this
> error:
>
>
>
> *       Falta la clase: org.dom4j.io.SAXReader*
>
> **
>
> *
>         Clase Dependiente: net.sf.jsfcomp.ext.onload.OnLoadPhaseListener*
>
> *                 Cargador: current-workspace-app.web.SiacAgenda
> :0.0.0*
>
> *            Origen de Código: /D:/OAS/SIACAGENDA/ViewController/public_html/WEB-INF/lib/jsfExt.jar
> Configuración: WEB-INF/lib/ directory in D:\OAS\SIACAGENDA\ViewController\public_html\WEB-INF\lib*
>
> *                  La clase que falta no está disponible desde ningún
> origen de código o cargador del sistema.*
>
>
>
> Do I have to put the dom jar on my project??
>
>
>
>   On Jan 8, 2008 9:50 PM, Andrew Robinson <an...@gmail.com>
> wrote:
>
> > Download the newest onload code (jsfExt.0.9.0):
> >
> > http://sourceforge.net/project/showfiles.php?group_id=137466&package_id=168611
> >
> >
> > (Sorry for the confusing release names)
> >
> > Other than that:
> >
> > "limpiarFormulario" should have a String, not void return type as it is
> > being used as an action.
> >
> > If that doesn't help, turn the logging up (it uses commons logging).
> >
> > If you really get stuck, you can compare your code to the demo WAR's
> > code.
> >
> > Your libraries should be fine.
> >
> >
> > On Jan 8, 2008 11:45 AM, daniel ccss < danielccss2@gmail.com> wrote:
> >
> > > What Im missing, this is what I do:
> > >
> > > 1- In the web.xml:
> > >     <context-param>
> > >             <param-name>onload-config</param-name>
> > >             <param-value>/WEB-INF/onload-config.xml</param-value>
> > >     </context-param>
> > > 2- In the faces-config.xml
> > >  <lifecycle>
> > >     ...
> > >     <phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener
> > > </phase-listener>
> > >  </lifecycle>
> > >
> > > ...
> > >  <managed-bean>
> > >     <description>Seguridad</description>
> > >     <managed-bean-name>SeguridadBean</managed-bean-name>
> > >     <managed-bean-class>persona.SeguridadBean</managed-bean-class>
> > >     <managed-bean-scope>session</managed-bean-scope>
> > >  </managed-bean>
> > > ...
> > >
> > > <navigation-rule>
> > >     <from-view-id>/JSP/Seguridad/Login.jsp</from-view-id>
> > >     <navigation-case>...
> > >
> > > 3- In the onload-config.xml
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <onload-config xmlns="urn:onload-config"
> > >             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >             xsi:schemaLocation="urn:onload-config onload-config.xsd">
> > >             <navigation-rule>
> > >                         <view-id>/JSP/Seguridad/Login.jsp</view-id>
> > >                         <action>#{SeguridadBean.limpiarFormulario
> > > }</action>
> > >             </navigation-rule>
> > > </onload-config>
> > >
> > > 4- I add the onload-config.xsd as is
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > >             targetNamespace="urn:onload-config"
> > >             xmlns="urn:onload-config"
> > >             elementFormDefault="qualified" version="1.0">
> > >             <xs:element name="onload-config" type="Config"/>
> > >             <xs:complexType name="Config">
> > >                         <xs:annotation>
> > >                                     <xs:documentation>
> > >                                                 Root element. Contains
> > > the configuration for the OnLoadPhaseListener
> > >                                     </xs:documentation>
> > >                         </xs:annotation>
> > >                         <xs:sequence maxOccurs="unbounded">
> > >                                     <xs:element name="navigation-rule"
> > > type="Rule"/>
> > >                         </xs:sequence>
> > >             </xs:complexType>
> > >             <xs:complexType name="Rule">
> > >                         <xs:annotation>
> > >                                     <xs:documentation>
> > >                                                 Defines the navigation
> > > rule for a JSF view-id or view-id pattern
> > >                                     </xs:documentation>
> > >                         </xs:annotation>
> > >                         <xs:sequence>
> > >                                     <xs:element name="view-id"
> > > type="ViewId"/>
> > >                                     <xs:element name="action"
> > > type="Action"/>
> > >                                     <xs:element name="success-result"
> > > type="SuccessResult" minOccurs="0"/>
> > >                         </xs:sequence>
> > >             </xs:complexType>
> > >             <xs:simpleType name="ViewId">
> > >                         <xs:annotation>
> > >                                     <xs:documentation>
> > >                                                 The view ID to match.
> > > This can be a full view-id or a path
> > >                                                 ending with an
> > > asterisk. Examples: /myDir/myFile.xhtml, /myDir/my*, *
> > >                                     </xs:documentation>
> > >                         </xs:annotation>
> > >                         <xs:restriction base="xs:string"/>
> > >             </xs:simpleType>
> > >             <xs:simpleType name="Action">
> > >                         <xs:annotation>
> > >                                     <xs:documentation>
> > >                                                 The EL syntax action
> > > name to invoke. This is the same syntax as
> > >                                                 when specifying an
> > > action in the JSF page.
> > >                                                 Example: #{
> > > myBean.myActionMethod}
> > >                                     </xs:documentation>
> > >                         </xs:annotation>
> > >                         <xs:restriction base="xs:string"/>
> > >             </xs:simpleType>
> > >             <xs:simpleType name="SuccessResult">
> > >                         <xs:annotation>
> > >                                     <xs:documentation>
> > >                                                 If the result of an
> > > action is null or equal to the success result,
> > >                                                 nothing is done. If
> > > the result is not equal to the success result
> > >                                                 the result is used to
> > > navigate to a new view based on the
> > >                                                 faces configuration
> > > file.
> > >                                     </xs:documentation>
> > >                         </xs:annotation>
> > >                         <xs:restriction base="xs:string"/>
> > >             </xs:simpleType>
> > >
> > > </xs:schema>
> > >
> > > 5- In SeguridadBean I add the method limpiarFormulario
> > >      public void limpiarFormulario(){
> > >          ...
> > >      }
> > >
> > >
> > > 6- I add the jar jsfExt.0.8.1 to web-inf
> > >
> > > The only differences that I saw was that I used:
> > > myfaces-api-1.1.5.jar
> > > myfaces-impl-1.1.5.jar
> > > commons-logging-1.1.jar
> > >
> > > I need to use my faces 1.1.5 and commons-logging-1.1, that is the
> > > problem? That´s why nothing happens?
> > > What I'm missing? I run the Login.jsp but the method limpiarFormulario
> > > was not called
> > >
> > > On Jan 8, 2008 3:24 PM, daniel ccss <da...@gmail.com> wrote:
> > >
> > > > Ok Andrew I will try it and tell you, thanks
> > > >
> > > >
> > > > On Jan 7, 2008 3:47 PM, Andrew Robinson <
> > > > andrew.rw.robinson@gmail.com> wrote:
> > > >
> > > > > Runs fine on JBoss if you aren't using Seam. If you are using seam
> > > > > use the "action" attribute in the pages.xml. It is basically the
> > > > > same thing. My on-load is nice for ppl. who want the functionality without
> > > > > adding a full framework
> > > > >
> > > > >
> > > > > On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:
> > > > >
> > > > > > Thanks Andrew, but i stop reading when saw this:
> > > > > > "
> > > > > > Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> > > > > > "
> > > > > >
> > > > > > Actually our project runs in OAS but we need for it to be
> > > > > > posible to run in JBoss also.
> > > > > >
> > > > > > Any other solution?
> > > > > >
> > > > > >   On Jan 7, 2008 3:33 PM, Andrew Robinson <
> > > > > > andrew.rw.robinson@gmail.com> wrote:
> > > > > >
> > > > > > > See my response. The simplest component is the jsf-comp one
> > > > > > > that I wrote:
> > > > > > >
> > > > > > > http://jsf-comp.sourceforge.net/components/onload/index.html
> > > > > > >
> > > > > > >
> > > > > > >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Thanks for the answers, I used a phaselistener but is for
> > > > > > > > all the application, like the one in the example of the login:
> > > > > > > >
> > > > > > > >  <phase-listener>
> > > > > > > > com.loffler.copycenter.controller.LoggedInCheck
> > > > > > > > </phase-listener>
> > > > > > > > but this type of listener is call for every Bean and my case
> > > > > > > > is different.
> > > > > > > >
> > > > > > > > Let me explain better my case, I have an App1 and App2, they
> > > > > > > > are in different servers, App1 have a link to call the App2, but I need do
> > > > > > > > some things before show the index of the App1, actually the link calls
> > > > > > > > directly the index.jsp of the App1, In this case I only need
> > > > > > > > the listener for do things when the App1 calls App2, something like in the
> > > > > > > > onload of the app2. Can I use a listener when a specific JSP is show? Can I
> > > > > > > > call directly the backing bean?
> > > > > > > >
> > > > > > > > thanks
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Can you do it in Spring?
> > > > > > > > >
> > > > > > > > > John
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > At 12:24 PM 1/7/2008, you wrote:
> > > > > > > > >
> > > > > > > > > Hi all,
> > > > > > > > >
> > > > > > > > > In struts:
> > > > > > > > > I can call a JSP page like http://..../JSP/Example.jsp and
> > > > > > > > > I also can call an action that do something and then do the forward to the
> > > > > > > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > > > > > > *
> > > > > > > > > In JSF:
> > > > > > > > > I can call a JSP page like http://...faces/JSP/Example.jsp
> > > > > > > > > *but *there is a way to call a backing bean before show
> > > > > > > > > the JSP?
> > > > > > > > >
> > > > > > > > > I need to do something in the backing bean (set some
> > > > > > > > > variables, etc) before showing the jsp, but I dont know if this is posible
> > > > > > > > > in JSF.
> > > > > > > > >
> > > > > > > > > thanks
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Andrew this new jar depends of the class: SAXReader?? I recived this error:



*       Falta la clase: org.dom4j.io.SAXReader*

**

*        Clase Dependiente: net.sf.jsfcomp.ext.onload.OnLoadPhaseListener*

*                 Cargador: current-workspace-app.web.SiacAgenda:0.0.0*

*            Origen de Código:
/D:/OAS/SIACAGENDA/ViewController/public_html/WEB-INF/lib/jsfExt.jar
       Configuración: WEB-INF/lib/ directory in
D:\OAS\SIACAGENDA\ViewController\public_html\WEB-INF\lib*

*                  La clase que falta no está disponible desde ningún origen
de código o cargador del sistema.*



Do I have to put the dom jar on my project??



On Jan 8, 2008 9:50 PM, Andrew Robinson <an...@gmail.com>
wrote:

> Download the newest onload code (jsfExt.0.9.0):
>
> http://sourceforge.net/project/showfiles.php?group_id=137466&package_id=168611
>
>
> (Sorry for the confusing release names)
>
> Other than that:
>
> "limpiarFormulario" should have a String, not void return type as it is
> being used as an action.
>
> If that doesn't help, turn the logging up (it uses commons logging).
>
> If you really get stuck, you can compare your code to the demo WAR's code.
>
> Your libraries should be fine.
>
>
> On Jan 8, 2008 11:45 AM, daniel ccss < danielccss2@gmail.com> wrote:
>
> > What Im missing, this is what I do:
> >
> > 1- In the web.xml:
> >     <context-param>
> >             <param-name>onload-config</param-name>
> >             <param-value>/WEB-INF/onload-config.xml</param-value>
> >     </context-param>
> > 2- In the faces-config.xml
> >  <lifecycle>
> >     ...
> >     <phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener
> > </phase-listener>
> >  </lifecycle>
> >
> > ...
> >  <managed-bean>
> >     <description>Seguridad</description>
> >     <managed-bean-name>SeguridadBean</managed-bean-name>
> >     <managed-bean-class>persona.SeguridadBean</managed-bean-class>
> >     <managed-bean-scope>session</managed-bean-scope>
> >  </managed-bean>
> > ...
> >
> > <navigation-rule>
> >     <from-view-id>/JSP/Seguridad/Login.jsp</from-view-id>
> >     <navigation-case>...
> >
> > 3- In the onload-config.xml
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <onload-config xmlns="urn:onload-config"
> >             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >             xsi:schemaLocation="urn:onload-config onload-config.xsd">
> >             <navigation-rule>
> >                         <view-id>/JSP/Seguridad/Login.jsp</view-id>
> >                         <action>#{SeguridadBean.limpiarFormulario
> > }</action>
> >             </navigation-rule>
> > </onload-config>
> >
> > 4- I add the onload-config.xsd as is
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >             targetNamespace="urn:onload-config"
> >             xmlns="urn:onload-config"
> >             elementFormDefault="qualified" version="1.0">
> >             <xs:element name="onload-config" type="Config"/>
> >             <xs:complexType name="Config">
> >                         <xs:annotation>
> >                                     <xs:documentation>
> >                                                 Root element. Contains
> > the configuration for the OnLoadPhaseListener
> >                                     </xs:documentation>
> >                         </xs:annotation>
> >                         <xs:sequence maxOccurs="unbounded">
> >                                     <xs:element name="navigation-rule"
> > type="Rule"/>
> >                         </xs:sequence>
> >             </xs:complexType>
> >             <xs:complexType name="Rule">
> >                         <xs:annotation>
> >                                     <xs:documentation>
> >                                                 Defines the navigation
> > rule for a JSF view-id or view-id pattern
> >                                     </xs:documentation>
> >                         </xs:annotation>
> >                         <xs:sequence>
> >                                     <xs:element name="view-id"
> > type="ViewId"/>
> >                                     <xs:element name="action"
> > type="Action"/>
> >                                     <xs:element name="success-result"
> > type="SuccessResult" minOccurs="0"/>
> >                         </xs:sequence>
> >             </xs:complexType>
> >             <xs:simpleType name="ViewId">
> >                         <xs:annotation>
> >                                     <xs:documentation>
> >                                                 The view ID to match.
> > This can be a full view-id or a path
> >                                                 ending with an asterisk.
> > Examples: /myDir/myFile.xhtml, /myDir/my*, *
> >                                     </xs:documentation>
> >                         </xs:annotation>
> >                         <xs:restriction base="xs:string"/>
> >             </xs:simpleType>
> >             <xs:simpleType name="Action">
> >                         <xs:annotation>
> >                                     <xs:documentation>
> >                                                 The EL syntax action
> > name to invoke. This is the same syntax as
> >                                                 when specifying an
> > action in the JSF page.
> >                                                 Example: #{
> > myBean.myActionMethod}
> >                                     </xs:documentation>
> >                         </xs:annotation>
> >                         <xs:restriction base="xs:string"/>
> >             </xs:simpleType>
> >             <xs:simpleType name="SuccessResult">
> >                         <xs:annotation>
> >                                     <xs:documentation>
> >                                                 If the result of an
> > action is null or equal to the success result,
> >                                                 nothing is done. If the
> > result is not equal to the success result
> >                                                 the result is used to
> > navigate to a new view based on the
> >                                                 faces configuration
> > file.
> >                                     </xs:documentation>
> >                         </xs:annotation>
> >                         <xs:restriction base="xs:string"/>
> >             </xs:simpleType>
> >
> > </xs:schema>
> >
> > 5- In SeguridadBean I add the method limpiarFormulario
> >      public void limpiarFormulario(){
> >          ...
> >      }
> >
> >
> > 6- I add the jar jsfExt.0.8.1 to web-inf
> >
> > The only differences that I saw was that I used:
> > myfaces-api-1.1.5.jar
> > myfaces-impl-1.1.5.jar
> > commons-logging-1.1.jar
> >
> > I need to use my faces 1.1.5 and commons-logging-1.1, that is the
> > problem? That´s why nothing happens?
> > What I'm missing? I run the Login.jsp but the method limpiarFormulario
> > was not called
> >
> > On Jan 8, 2008 3:24 PM, daniel ccss <da...@gmail.com> wrote:
> >
> > > Ok Andrew I will try it and tell you, thanks
> > >
> > >
> > > On Jan 7, 2008 3:47 PM, Andrew Robinson <an...@gmail.com>
> > > wrote:
> > >
> > > > Runs fine on JBoss if you aren't using Seam. If you are using seam
> > > > use the "action" attribute in the pages.xml. It is basically the
> > > > same thing. My on-load is nice for ppl. who want the functionality without
> > > > adding a full framework
> > > >
> > > >
> > > > On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:
> > > >
> > > > > Thanks Andrew, but i stop reading when saw this:
> > > > > "
> > > > > Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> > > > > "
> > > > >
> > > > > Actually our project runs in OAS but we need for it to be posible
> > > > > to run in JBoss also.
> > > > >
> > > > > Any other solution?
> > > > >
> > > > >   On Jan 7, 2008 3:33 PM, Andrew Robinson <
> > > > > andrew.rw.robinson@gmail.com> wrote:
> > > > >
> > > > > > See my response. The simplest component is the jsf-comp one that
> > > > > > I wrote:
> > > > > >
> > > > > > http://jsf-comp.sourceforge.net/components/onload/index.html
> > > > > >
> > > > > >
> > > > > >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > Thanks for the answers, I used a phaselistener but is for all
> > > > > > > the application, like the one in the example of the login:
> > > > > > >
> > > > > > >  <phase-listener>
> > > > > > > com.loffler.copycenter.controller.LoggedInCheck
> > > > > > > </phase-listener>
> > > > > > > but this type of listener is call for every Bean and my case
> > > > > > > is different.
> > > > > > >
> > > > > > > Let me explain better my case, I have an App1 and App2, they
> > > > > > > are in different servers, App1 have a link to call the App2, but I need do
> > > > > > > some things before show the index of the App1, actually the link calls
> > > > > > > directly the index.jsp of the App1, In this case I only need
> > > > > > > the listener for do things when the App1 calls App2, something like in the
> > > > > > > onload of the app2. Can I use a listener when a specific JSP is show? Can I
> > > > > > > call directly the backing bean?
> > > > > > >
> > > > > > > thanks
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Can you do it in Spring?
> > > > > > > >
> > > > > > > > John
> > > > > > > >
> > > > > > > >
> > > > > > > > At 12:24 PM 1/7/2008, you wrote:
> > > > > > > >
> > > > > > > > Hi all,
> > > > > > > >
> > > > > > > > In struts:
> > > > > > > > I can call a JSP page like http://..../JSP/Example.jsp and I
> > > > > > > > also can call an action that do something and then do the forward to the
> > > > > > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > > > > > *
> > > > > > > > In JSF:
> > > > > > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but
> > > > > > > > *there is a way to call a backing bean before show the JSP?
> > > > > > > >
> > > > > > > > I need to do something in the backing bean (set some
> > > > > > > > variables, etc) before showing the jsp, but I dont know if this is posible
> > > > > > > > in JSF.
> > > > > > > >
> > > > > > > > thanks
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by Andrew Robinson <an...@gmail.com>.
Download the newest onload code (jsfExt.0.9.0):

http://sourceforge.net/project/showfiles.php?group_id=137466&package_id=168611

(Sorry for the confusing release names)

Other than that:

"limpiarFormulario" should have a String, not void return type as it is
being used as an action.

If that doesn't help, turn the logging up (it uses commons logging).

If you really get stuck, you can compare your code to the demo WAR's code.

Your libraries should be fine.

On Jan 8, 2008 11:45 AM, daniel ccss <da...@gmail.com> wrote:

> What Im missing, this is what I do:
>
> 1- In the web.xml:
>     <context-param>
>             <param-name>onload-config</param-name>
>             <param-value>/WEB-INF/onload-config.xml</param-value>
>     </context-param>
> 2- In the faces-config.xml
>  <lifecycle>
>     ...
>     <phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener
> </phase-listener>
>  </lifecycle>
>
> ...
>  <managed-bean>
>     <description>Seguridad</description>
>     <managed-bean-name>SeguridadBean</managed-bean-name>
>     <managed-bean-class>persona.SeguridadBean</managed-bean-class>
>     <managed-bean-scope>session</managed-bean-scope>
>  </managed-bean>
> ...
>
> <navigation-rule>
>     <from-view-id>/JSP/Seguridad/Login.jsp</from-view-id>
>     <navigation-case>...
>
> 3- In the onload-config.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <onload-config xmlns="urn:onload-config"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>             xsi:schemaLocation="urn:onload-config onload-config.xsd">
>             <navigation-rule>
>                         <view-id>/JSP/Seguridad/Login.jsp</view-id>
>                         <action>#{SeguridadBean.limpiarFormulario
> }</action>
>             </navigation-rule>
> </onload-config>
>
> 4- I add the onload-config.xsd as is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>             targetNamespace="urn:onload-config"
>             xmlns="urn:onload-config"
>             elementFormDefault="qualified" version="1.0">
>             <xs:element name="onload-config" type="Config"/>
>             <xs:complexType name="Config">
>                         <xs:annotation>
>                                     <xs:documentation>
>                                                 Root element. Contains the
> configuration for the OnLoadPhaseListener
>                                     </xs:documentation>
>                         </xs:annotation>
>                         <xs:sequence maxOccurs="unbounded">
>                                     <xs:element name="navigation-rule"
> type="Rule"/>
>                         </xs:sequence>
>             </xs:complexType>
>             <xs:complexType name="Rule">
>                         <xs:annotation>
>                                     <xs:documentation>
>                                                 Defines the navigation
> rule for a JSF view-id or view-id pattern
>                                     </xs:documentation>
>                         </xs:annotation>
>                         <xs:sequence>
>                                     <xs:element name="view-id"
> type="ViewId"/>
>                                     <xs:element name="action"
> type="Action"/>
>                                     <xs:element name="success-result"
> type="SuccessResult" minOccurs="0"/>
>                         </xs:sequence>
>             </xs:complexType>
>             <xs:simpleType name="ViewId">
>                         <xs:annotation>
>                                     <xs:documentation>
>                                                 The view ID to match. This
> can be a full view-id or a path
>                                                 ending with an asterisk.
> Examples: /myDir/myFile.xhtml, /myDir/my*, *
>                                     </xs:documentation>
>                         </xs:annotation>
>                         <xs:restriction base="xs:string"/>
>             </xs:simpleType>
>             <xs:simpleType name="Action">
>                         <xs:annotation>
>                                     <xs:documentation>
>                                                 The EL syntax action name
> to invoke. This is the same syntax as
>                                                 when specifying an action
> in the JSF page.
>                                                 Example: #{
> myBean.myActionMethod}
>                                     </xs:documentation>
>                         </xs:annotation>
>                         <xs:restriction base="xs:string"/>
>             </xs:simpleType>
>             <xs:simpleType name="SuccessResult">
>                         <xs:annotation>
>                                     <xs:documentation>
>                                                 If the result of an action
> is null or equal to the success result,
>                                                 nothing is done. If the
> result is not equal to the success result
>                                                 the result is used to
> navigate to a new view based on the
>                                                 faces configuration file.
>                                     </xs:documentation>
>                         </xs:annotation>
>                         <xs:restriction base="xs:string"/>
>             </xs:simpleType>
>
> </xs:schema>
>
> 5- In SeguridadBean I add the method limpiarFormulario
>      public void limpiarFormulario(){
>          ...
>      }
>
>
> 6- I add the jar jsfExt.0.8.1 to web-inf
>
> The only differences that I saw was that I used:
> myfaces-api-1.1.5.jar
> myfaces-impl-1.1.5.jar
> commons-logging-1.1.jar
>
> I need to use my faces 1.1.5 and commons-logging-1.1, that is the problem?
> That´s why nothing happens?
> What I'm missing? I run the Login.jsp but the method limpiarFormulario was
> not called
>
> On Jan 8, 2008 3:24 PM, daniel ccss <da...@gmail.com> wrote:
>
> > Ok Andrew I will try it and tell you, thanks
> >
> >
> > On Jan 7, 2008 3:47 PM, Andrew Robinson <an...@gmail.com>
> > wrote:
> >
> > > Runs fine on JBoss if you aren't using Seam. If you are using seam use
> > > the "action" attribute in the pages.xml. It is basically the same
> > > thing. My on-load is nice for ppl. who want the functionality without adding
> > > a full framework
> > >
> > >
> > > On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:
> > >
> > > > Thanks Andrew, but i stop reading when saw this:
> > > > "
> > > > Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> > > > "
> > > >
> > > > Actually our project runs in OAS but we need for it to be posible to
> > > > run in JBoss also.
> > > >
> > > > Any other solution?
> > > >
> > > >   On Jan 7, 2008 3:33 PM, Andrew Robinson <
> > > > andrew.rw.robinson@gmail.com> wrote:
> > > >
> > > > > See my response. The simplest component is the jsf-comp one that I
> > > > > wrote:
> > > > >
> > > > > http://jsf-comp.sourceforge.net/components/onload/index.html
> > > > >
> > > > >
> > > > >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > Thanks for the answers, I used a phaselistener but is for all
> > > > > > the application, like the one in the example of the login:
> > > > > >
> > > > > >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > > > > > </phase-listener>
> > > > > > but this type of listener is call for every Bean and my case is
> > > > > > different.
> > > > > >
> > > > > > Let me explain better my case, I have an App1 and App2, they are
> > > > > > in different servers, App1 have a link to call the App2, but I need do some
> > > > > > things before show the index of the App1, actually the link calls directly
> > > > > > the index.jsp of the App1, In this case I only need the listener
> > > > > > for do things when the App1 calls App2, something like in the onload of the
> > > > > > app2. Can I use a listener when a specific JSP is show? Can I call directly
> > > > > > the backing bean?
> > > > > >
> > > > > > thanks
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> > > > > >
> > > > > > > Can you do it in Spring?
> > > > > > >
> > > > > > > John
> > > > > > >
> > > > > > >
> > > > > > > At 12:24 PM 1/7/2008, you wrote:
> > > > > > >
> > > > > > > Hi all,
> > > > > > >
> > > > > > > In struts:
> > > > > > > I can call a JSP page like http://..../JSP/Example.jsp and I
> > > > > > > also can call an action that do something and then do the forward to the
> > > > > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > > > > *
> > > > > > > In JSF:
> > > > > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but
> > > > > > > *there is a way to call a backing bean before show the JSP?
> > > > > > >
> > > > > > > I need to do something in the backing bean (set some
> > > > > > > variables, etc) before showing the jsp, but I dont know if this is posible
> > > > > > > in JSF.
> > > > > > >
> > > > > > > thanks
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
What Im missing, this is what I do:

1- In the web.xml:
    <context-param>
            <param-name>onload-config</param-name>
            <param-value>/WEB-INF/onload-config.xml</param-value>
    </context-param>
2- In the faces-config.xml
 <lifecycle>
    ...
    <phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener
</phase-listener>
 </lifecycle>

...
 <managed-bean>
    <description>Seguridad</description>
    <managed-bean-name>SeguridadBean</managed-bean-name>
    <managed-bean-class>persona.SeguridadBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
...

<navigation-rule>
    <from-view-id>/JSP/Seguridad/Login.jsp</from-view-id>
    <navigation-case>...

3- In the onload-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<onload-config xmlns="urn:onload-config"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:onload-config onload-config.xsd">
            <navigation-rule>
                        <view-id>/JSP/Seguridad/Login.jsp</view-id>
                        <action>#{SeguridadBean.limpiarFormulario}</action>
            </navigation-rule>
</onload-config>

4- I add the onload-config.xsd as is

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="urn:onload-config"
            xmlns="urn:onload-config"
            elementFormDefault="qualified" version="1.0">
            <xs:element name="onload-config" type="Config"/>
            <xs:complexType name="Config">
                        <xs:annotation>
                                    <xs:documentation>
                                                Root element. Contains the
configuration for the OnLoadPhaseListener
                                    </xs:documentation>
                        </xs:annotation>
                        <xs:sequence maxOccurs="unbounded">
                                    <xs:element name="navigation-rule"
type="Rule"/>
                        </xs:sequence>
            </xs:complexType>
            <xs:complexType name="Rule">
                        <xs:annotation>
                                    <xs:documentation>
                                                Defines the navigation rule
for a JSF view-id or view-id pattern
                                    </xs:documentation>
                        </xs:annotation>
                        <xs:sequence>
                                    <xs:element name="view-id"
type="ViewId"/>
                                    <xs:element name="action"
type="Action"/>
                                    <xs:element name="success-result"
type="SuccessResult" minOccurs="0"/>
                        </xs:sequence>
            </xs:complexType>
            <xs:simpleType name="ViewId">
                        <xs:annotation>
                                    <xs:documentation>
                                                The view ID to match. This
can be a full view-id or a path
                                                ending with an asterisk.
Examples: /myDir/myFile.xhtml, /myDir/my*, *
                                    </xs:documentation>
                        </xs:annotation>
                        <xs:restriction base="xs:string"/>
            </xs:simpleType>
            <xs:simpleType name="Action">
                        <xs:annotation>
                                    <xs:documentation>
                                                The EL syntax action name to
invoke. This is the same syntax as
                                                when specifying an action in
the JSF page.
                                                Example: #{
myBean.myActionMethod}
                                    </xs:documentation>
                        </xs:annotation>
                        <xs:restriction base="xs:string"/>
            </xs:simpleType>
            <xs:simpleType name="SuccessResult">
                        <xs:annotation>
                                    <xs:documentation>
                                                If the result of an action
is null or equal to the success result,
                                                nothing is done. If the
result is not equal to the success result
                                                the result is used to
navigate to a new view based on the
                                                faces configuration file.
                                    </xs:documentation>
                        </xs:annotation>
                        <xs:restriction base="xs:string"/>
            </xs:simpleType>

</xs:schema>

5- In SeguridadBean I add the method limpiarFormulario
     public void limpiarFormulario(){
         ...
     }


6- I add the jar jsfExt.0.8.1 to web-inf

The only differences that I saw was that I used:
myfaces-api-1.1.5.jar
myfaces-impl-1.1.5.jar
commons-logging-1.1.jar

I need to use my faces 1.1.5 and commons-logging-1.1, that is the problem?
That´s why nothing happens?
What I'm missing? I run the Login.jsp but the method limpiarFormulario was
not called

On Jan 8, 2008 3:24 PM, daniel ccss <da...@gmail.com> wrote:

> Ok Andrew I will try it and tell you, thanks
>
>
> On Jan 7, 2008 3:47 PM, Andrew Robinson <an...@gmail.com>
> wrote:
>
> > Runs fine on JBoss if you aren't using Seam. If you are using seam use
> > the "action" attribute in the pages.xml. It is basically the same thing.
> > My on-load is nice for ppl. who want the functionality without adding a full
> > framework
> >
> >
> > On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:
> >
> > > Thanks Andrew, but i stop reading when saw this:
> > > "
> > > Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> > > "
> > >
> > > Actually our project runs in OAS but we need for it to be posible to
> > > run in JBoss also.
> > >
> > > Any other solution?
> > >
> > >   On Jan 7, 2008 3:33 PM, Andrew Robinson <
> > > andrew.rw.robinson@gmail.com> wrote:
> > >
> > > > See my response. The simplest component is the jsf-comp one that I
> > > > wrote:
> > > >
> > > > http://jsf-comp.sourceforge.net/components/onload/index.html
> > > >
> > > >
> > > >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:
> > > >
> > > > > Thanks for the answers, I used a phaselistener but is for all the
> > > > > application, like the one in the example of the login:
> > > > >
> > > > >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > > > > </phase-listener>
> > > > > but this type of listener is call for every Bean and my case is
> > > > > different.
> > > > >
> > > > > Let me explain better my case, I have an App1 and App2, they are
> > > > > in different servers, App1 have a link to call the App2, but I need do some
> > > > > things before show the index of the App1, actually the link calls directly
> > > > > the index.jsp of the App1, In this case I only need the listener
> > > > > for do things when the App1 calls App2, something like in the onload of the
> > > > > app2. Can I use a listener when a specific JSP is show? Can I call directly
> > > > > the backing bean?
> > > > >
> > > > > thanks
> > > > >
> > > > >
> > > > >
> > > > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> > > > >
> > > > > > Can you do it in Spring?
> > > > > >
> > > > > > John
> > > > > >
> > > > > >
> > > > > > At 12:24 PM 1/7/2008, you wrote:
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > In struts:
> > > > > > I can call a JSP page like http://..../JSP/Example.jsp and I
> > > > > > also can call an action that do something and then do the forward to the
> > > > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > > > *
> > > > > > In JSF:
> > > > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but
> > > > > > *there is a way to call a backing bean before show the JSP?
> > > > > >
> > > > > > I need to do something in the backing bean (set some variables,
> > > > > > etc) before showing the jsp, but I dont know if this is posible in JSF.
> > > > > >
> > > > > > thanks
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Ok Andrew I will try it and tell you, thanks

On Jan 7, 2008 3:47 PM, Andrew Robinson <an...@gmail.com>
wrote:

> Runs fine on JBoss if you aren't using Seam. If you are using seam use the
> "action" attribute in the pages.xml. It is basically the same thing. My
> on-load is nice for ppl. who want the functionality without adding a full
> framework
>
>
> On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:
>
> > Thanks Andrew, but i stop reading when saw this:
> > "
> > Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> > "
> >
> > Actually our project runs in OAS but we need for it to be posible to run
> > in JBoss also.
> >
> > Any other solution?
> >
> >   On Jan 7, 2008 3:33 PM, Andrew Robinson <an...@gmail.com>
> > wrote:
> >
> > > See my response. The simplest component is the jsf-comp one that I
> > > wrote:
> > >
> > > http://jsf-comp.sourceforge.net/components/onload/index.html
> > >
> > >
> > >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:
> > >
> > > > Thanks for the answers, I used a phaselistener but is for all the
> > > > application, like the one in the example of the login:
> > > >
> > > >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > > > </phase-listener>
> > > > but this type of listener is call for every Bean and my case is
> > > > different.
> > > >
> > > > Let me explain better my case, I have an App1 and App2, they are in
> > > > different servers, App1 have a link to call the App2, but I need do some
> > > > things before show the index of the App1, actually the link calls directly
> > > > the index.jsp of the App1, In this case I only need the listener for
> > > > do things when the App1 calls App2, something like in the onload of the
> > > > app2. Can I use a listener when a specific JSP is show? Can I call directly
> > > > the backing bean?
> > > >
> > > > thanks
> > > >
> > > >
> > > >
> > > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> > > >
> > > > > Can you do it in Spring?
> > > > >
> > > > > John
> > > > >
> > > > >
> > > > > At 12:24 PM 1/7/2008, you wrote:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > In struts:
> > > > > I can call a JSP page like http://..../JSP/Example.jsp and I also
> > > > > can call an action that do something and then do the forward to the
> > > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > > *
> > > > > In JSF:
> > > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > > > > is a way to call a backing bean before show the JSP?
> > > > >
> > > > > I need to do something in the backing bean (set some variables,
> > > > > etc) before showing the jsp, but I dont know if this is posible in JSF.
> > > > >
> > > > > thanks
> > > > >
> > > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by Andrew Robinson <an...@gmail.com>.
Runs fine on JBoss if you aren't using Seam. If you are using seam use the
"action" attribute in the pages.xml. It is basically the same thing. My
on-load is nice for ppl. who want the functionality without adding a full
framework

On Jan 7, 2008 2:37 PM, daniel ccss <da...@gmail.com> wrote:

> Thanks Andrew, but i stop reading when saw this:
> "
> Note: If you are using JBoss Seam you cannot use it due to Seam configuration conflicts.
> "
>
> Actually our project runs in OAS but we need for it to be posible to run
> in JBoss also.
>
> Any other solution?
>
> On Jan 7, 2008 3:33 PM, Andrew Robinson <an...@gmail.com>
> wrote:
>
> > See my response. The simplest component is the jsf-comp one that I
> > wrote:
> >
> > http://jsf-comp.sourceforge.net/components/onload/index.html
> >
> >
> >  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:
> >
> > > Thanks for the answers, I used a phaselistener but is for all the
> > > application, like the one in the example of the login:
> > >
> > >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > > </phase-listener>
> > > but this type of listener is call for every Bean and my case is
> > > different.
> > >
> > > Let me explain better my case, I have an App1 and App2, they are in
> > > different servers, App1 have a link to call the App2, but I need do some
> > > things before show the index of the App1, actually the link calls directly
> > > the index.jsp of the App1, In this case I only need the listener for
> > > do things when the App1 calls App2, something like in the onload of the
> > > app2. Can I use a listener when a specific JSP is show? Can I call directly
> > > the backing bean?
> > >
> > > thanks
> > >
> > >
> > >
> > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> > >
> > > > Can you do it in Spring?
> > > >
> > > > John
> > > >
> > > >
> > > > At 12:24 PM 1/7/2008, you wrote:
> > > >
> > > > Hi all,
> > > >
> > > > In struts:
> > > > I can call a JSP page like http://..../JSP/Example.jsp and I also
> > > > can call an action that do something and then do the forward to the
> > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > *
> > > > In JSF:
> > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > > > is a way to call a backing bean before show the JSP?
> > > >
> > > > I need to do something in the backing bean (set some variables, etc)
> > > > before showing the jsp, but I dont know if this is posible in JSF.
> > > >
> > > > thanks
> > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Thanks Andrew, but i stop reading when saw this:
"
Note: If you are using JBoss Seam you cannot use it due to Seam
configuration conflicts.
"

Actually our project runs in OAS but we need for it to be posible to run in
JBoss also.

Any other solution?

On Jan 7, 2008 3:33 PM, Andrew Robinson <an...@gmail.com>
wrote:

> See my response. The simplest component is the jsf-comp one that I wrote:
>
> http://jsf-comp.sourceforge.net/components/onload/index.html
>
>
>  On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:
>
> > Thanks for the answers, I used a phaselistener but is for all the
> > application, like the one in the example of the login:
> >
> >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > </phase-listener>
> > but this type of listener is call for every Bean and my case is
> > different.
> >
> > Let me explain better my case, I have an App1 and App2, they are in
> > different servers, App1 have a link to call the App2, but I need do some
> > things before show the index of the App1, actually the link calls directly
> > the index.jsp of the App1, In this case I only need the listener for do
> > things when the App1 calls App2, something like in the onload of the app2.
> > Can I use a listener when a specific JSP is show? Can I call directly the
> > backing bean?
> >
> > thanks
> >
> >
> >
> > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> >
> > > Can you do it in Spring?
> > >
> > > John
> > >
> > >
> > > At 12:24 PM 1/7/2008, you wrote:
> > >
> > > Hi all,
> > >
> > > In struts:
> > > I can call a JSP page like http://..../JSP/Example.jsp and I also can
> > > call an action that do something and then do the forward to the
> > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > *
> > > In JSF:
> > > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > > is a way to call a backing bean before show the JSP?
> > >
> > > I need to do something in the backing bean (set some variables, etc)
> > > before showing the jsp, but I dont know if this is posible in JSF.
> > >
> > > thanks
> > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by simon <si...@chello.at>.
Hi Daniel,

This pattern is generally called a "view controller".

The Apache Shale project has provided this for several years:
  http://shale.apache.org/shale-view/index.html

The MyFaces Orchestra project also provides a "view controller"
framework.

And the code Andrew links to is also a kind of "view controller",
although limited to just one function: "run logic before view".

I'm pretty sure that JBoss Seam also provides this kind of thing.

It is a shame that this isn't part of the JSF core, and maybe in future
it will be.

The problem in all cases is defining what logic will run for which
views. Shale and Orchestra have a default approach of looking for a
managed-bean whose name "matches" the view-id, although both can be
configured in various ways. Andrew's code uses a configuration file to
map viewid->action. I'm not sure what Seam does.

They are all valid ways of dealing with this problem. And most of them
actually use a PhaseListener to implement their logic.

Of course if you don't need to support the ability to navigate off to
some other page, then the simplest solution is just to put a component
at the top of each page that invokes the logic you want.

Regards,

Simon



On Mon, 2008-01-07 at 14:33 -0700, Andrew Robinson wrote:
> See my response. The simplest component is the jsf-comp one that I
> wrote:
> 
> http://jsf-comp.sourceforge.net/components/onload/index.html
> 
> 
> On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:
>         Thanks for the answers, I used a phaselistener but is for all
>         the application, like the one in the example of the login:
>          
>          <phase-listener>com.loffler.copycenter.controller.LoggedInCheck</phase-listener>
>         
>         but this type of listener is call for every Bean and my case
>         is different.
>          
>         Let me explain better my case, I have an App1 and App2, they
>         are in different servers, App1 have a link to call the App2,
>         but I need do some things before show the index of the App1,
>         actually the link calls directly the index.jsp of the App1, In
>         this case I only need the listener for do things when the App1
>         calls App2, something like in the onload of the app2. Can I
>         use a listener when a specific JSP is show? Can I call
>         directly the backing bean?
>          
>         thanks
>         
>          
>         
>          
>         On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov>
>         wrote:
>                 Can you do it in Spring?
>                 
>                 John  
>                 
>                 
>                 
>                 At 12:24 PM 1/7/2008, you wrote:
>                 
>                 > Hi all,
>                 > 
>                 > In struts:
>                 > I can call a JSP page like
>                 > http://..../JSP/Example.jsp and I also can call an
>                 > action that do something and then do the forward to
>                 > the Example.jsp like this: http:// .../Example.do
>                 > 
>                 > In JSF:
>                 > I can call a JSP page like
>                 > http://...faces/JSP/Example.jsp but there is a way
>                 > to call a backing bean before show the JSP?
>                 > 
>                 > I need to do something in the backing bean (set some
>                 > variables, etc) before showing the jsp, but I dont
>                 > know if this is posible in JSF. 
>                 > 
>                 > thanks
>         
>         
> 


Re: Call a backing bean before show a JSP

Posted by Andrew Robinson <an...@gmail.com>.
See my response. The simplest component is the jsf-comp one that I wrote:

http://jsf-comp.sourceforge.net/components/onload/index.html


On Jan 7, 2008 2:26 PM, daniel ccss <da...@gmail.com> wrote:

> Thanks for the answers, I used a phaselistener but is for all the
> application, like the one in the example of the login:
>
>  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> </phase-listener>
> but this type of listener is call for every Bean and my case is different.
>
> Let me explain better my case, I have an App1 and App2, they are in
> different servers, App1 have a link to call the App2, but I need do some
> things before show the index of the App1, actually the link calls directly
> the index.jsp of the App1, In this case I only need the listener for do
> things when the App1 calls App2, something like in the onload of the app2.
> Can I use a listener when a specific JSP is show? Can I call directly the
> backing bean?
>
> thanks
>
>
>
> On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
>
> > Can you do it in Spring?
> >
> > John
> >
> >
> > At 12:24 PM 1/7/2008, you wrote:
> >
> > Hi all,
> >
> > In struts:
> > I can call a JSP page like http://..../JSP/Example.jsp and I also can
> > call an action that do something and then do the forward to the
> > Example.jsp like this: http:// <http:///> .../Example*.do
> > *
> > In JSF:
> > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > is a way to call a backing bean before show the JSP?
> >
> > I need to do something in the backing bean (set some variables, etc)
> > before showing the jsp, but I dont know if this is posible in JSF.
> >
> > thanks
> >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
humm :( the problem is that my bean`s scope is session and not request, so
Ì`m can´t use the managed-property :(

Any other solution?
Andrew what´s wrong with my jsf-comp implementation?

Need help with this plz.
On Jan 8, 2008 7:49 PM, daniel ccss <da...@gmail.com> wrote:

> Sven this looks pretty easy i'm gonna try it and let you know thanks.
>
>
> On Jan 8, 2008 9:36 AM, Rottstock, Sven <Sv...@sungard.de> wrote:
>
> >  Why don't you use managed-properties for this scenario? You can call
> > your action method in App1; put some parameters in the URL and forward to
> > App2. If you use a request bean in your index.jsp (App2) then you can
> > initialize your bean with the paramaters from App1 like this:
> > <managed-bean>
> >   <managed-bean-name>initBean</managed-bean-name>
> >   <managed-bean-class>my.package.InitBean</managed-bean-class>
> >   <managed-bean-scope>request</managed-bean-scope>
> >   <managed-property>
> >     <property-name>param</property-name>
> >     <value>#{param['whatever']}</value>
> >   </managed-property>
> > <managed-bean>
> >
> > Cheers
> >
> > Sven
> >
> >  ------------------------------
> > *Von:* daniel ccss [mailto:danielccss2@gmail.com]
> > *Gesendet:* Montag, 7. Januar 2008 22:30
> > *An:* MyFaces Discussion
> > *Betreff:* Re: Call a backing bean before show a JSP
> >
> >   Sorry, this is the correct question, I have a mistake on the App # :P
> >
> > Let me explain better my case, I have an App1 and App2, they are in
> > different servers, App1 have a link to call the App2, but I need do some
> > things before show the index of the App*2*, actually the link calls
> > directly the index.jsp of the App*2*, In this case I only need the
> > listener for do things when the App1 calls App2, something like in the
> > onload of the App2. Can I use a listener when a specific JSP is show? Can I
> > call directly the backing bean?
> >
> > thanks again
> >
> > On Jan 7, 2008 3:26 PM, daniel ccss <da...@gmail.com> wrote:
> >
> > > Thanks for the answers, I used a phaselistener but is for all the
> > > application, like the one in the example of the login:
> > >
> > >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > > </phase-listener>
> > > but this type of listener is call for every Bean and my case is
> > > different.
> > >
> > > Let me explain better my case, I have an App1 and App2, they are in
> > > different servers, App1 have a link to call the App2, but I need do some
> > > things before show the index of the App*2*, actually the link calls
> > > directly the index.jsp of the App*2*, In this case I only need the
> > > listener for do things when the App1 calls App2, something like in the
> > > onload of the App2. Can I use a listener when a specific JSP is show? Can I
> > > call directly the backing bean?
> > >
> > > thanks
> > >
> > >
> > >
> > > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> > >
> > > > Can you do it in Spring?
> > > >
> > > > John
> > > >
> > > >
> > > > At 12:24 PM 1/7/2008, you wrote:
> > > >
> > > > Hi all,
> > > >
> > > > In struts:
> > > > I can call a JSP page like http://..../JSP/Example.jsp and I also
> > > > can call an action that do something and then do the forward to the
> > > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > > *
> > > > In JSF:
> > > > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > > > is a way to call a backing bean before show the JSP?
> > > >
> > > > I need to do something in the backing bean (set some variables, etc)
> > > > before showing the jsp, but I dont know if this is posible in JSF.
> > > >
> > > > thanks
> > > >
> > > >
> > >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Sven this looks pretty easy i'm gonna try it and let you know thanks.

On Jan 8, 2008 9:36 AM, Rottstock, Sven <Sv...@sungard.de> wrote:

>  Why don't you use managed-properties for this scenario? You can call your
> action method in App1; put some parameters in the URL and forward to App2.
> If you use a request bean in your index.jsp (App2) then you can initialize
> your bean with the paramaters from App1 like this:
> <managed-bean>
>   <managed-bean-name>initBean</managed-bean-name>
>   <managed-bean-class>my.package.InitBean</managed-bean-class>
>   <managed-bean-scope>request</managed-bean-scope>
>   <managed-property>
>     <property-name>param</property-name>
>     <value>#{param['whatever']}</value>
>   </managed-property>
> <managed-bean>
>
> Cheers
>
> Sven
>
>  ------------------------------
> *Von:* daniel ccss [mailto:danielccss2@gmail.com]
> *Gesendet:* Montag, 7. Januar 2008 22:30
> *An:* MyFaces Discussion
> *Betreff:* Re: Call a backing bean before show a JSP
>
>   Sorry, this is the correct question, I have a mistake on the App # :P
>
> Let me explain better my case, I have an App1 and App2, they are in
> different servers, App1 have a link to call the App2, but I need do some
> things before show the index of the App*2*, actually the link calls
> directly the index.jsp of the App*2*, In this case I only need the
> listener for do things when the App1 calls App2, something like in the
> onload of the App2. Can I use a listener when a specific JSP is show? Can I
> call directly the backing bean?
>
> thanks again
>
> On Jan 7, 2008 3:26 PM, daniel ccss <da...@gmail.com> wrote:
>
> > Thanks for the answers, I used a phaselistener but is for all the
> > application, like the one in the example of the login:
> >
> >  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> > </phase-listener>
> > but this type of listener is call for every Bean and my case is
> > different.
> >
> > Let me explain better my case, I have an App1 and App2, they are in
> > different servers, App1 have a link to call the App2, but I need do some
> > things before show the index of the App*2*, actually the link calls
> > directly the index.jsp of the App*2*, In this case I only need the
> > listener for do things when the App1 calls App2, something like in the
> > onload of the App2. Can I use a listener when a specific JSP is show? Can I
> > call directly the backing bean?
> >
> > thanks
> >
> >
> >
> > On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
> >
> > > Can you do it in Spring?
> > >
> > > John
> > >
> > >
> > > At 12:24 PM 1/7/2008, you wrote:
> > >
> > > Hi all,
> > >
> > > In struts:
> > > I can call a JSP page like http://..../JSP/Example.jsp and I also can
> > > call an action that do something and then do the forward to the
> > > Example.jsp like this: http:// <http:///> .../Example*.do
> > > *
> > > In JSF:
> > > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > > is a way to call a backing bean before show the JSP?
> > >
> > > I need to do something in the backing bean (set some variables, etc)
> > > before showing the jsp, but I dont know if this is posible in JSF.
> > >
> > > thanks
> > >
> > >
> >
>

AW: Call a backing bean before show a JSP

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Why don't you use managed-properties for this scenario? You can call
your action method in App1; put some parameters in the URL and forward
to App2. If you use a request bean in your index.jsp (App2) then you can
initialize your bean with the paramaters from App1 like this:
<managed-bean>
  <managed-bean-name>initBean</managed-bean-name>
  <managed-bean-class>my.package.InitBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  <managed-property>
    <property-name>param</property-name>
    <value>#{param['whatever']}</value>
  </managed-property>
<managed-bean>
 
Cheers
 
Sven

________________________________

Von: daniel ccss [mailto:danielccss2@gmail.com] 
Gesendet: Montag, 7. Januar 2008 22:30
An: MyFaces Discussion
Betreff: Re: Call a backing bean before show a JSP


Sorry, this is the correct question, I have a mistake on the App # :P
 
Let me explain better my case, I have an App1 and App2, they are in
different servers, App1 have a link to call the App2, but I need do some
things before show the index of the App2, actually the link calls
directly the index.jsp of the App2, In this case I only need the
listener for do things when the App1 calls App2, something like in the
onload of the App2. Can I use a listener when a specific JSP is show?
Can I call directly the backing bean? 
 
thanks again


On Jan 7, 2008 3:26 PM, daniel ccss <da...@gmail.com> wrote:


	Thanks for the answers, I used a phaselistener but is for all
the application, like the one in the example of the login:
	 
	
<phase-listener>com.loffler.copycenter.controller.LoggedInCheck</phase-l
istener>
	
	but this type of listener is call for every Bean and my case is
different.
	 
	Let me explain better my case, I have an App1 and App2, they are
in different servers, App1 have a link to call the App2, but I need do
some things before show the index of the App2, actually the link calls
directly the index.jsp of the App2, In this case I only need the
listener for do things when the App1 calls App2, something like in the
onload of the App2. Can I use a listener when a specific JSP is show?
Can I call directly the backing bean? 
	 
	thanks
	 

	 
	On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
	

		Can you do it in Spring?
		
		John 


		At 12:24 PM 1/7/2008, you wrote:
		
		

			Hi all,
			
			In struts:
			I can call a JSP page like
http://..../JSP/Example.jsp and I also can call an action that do
something and then do the forward to the Example.jsp like this: http://
<http:///>  .../Example.do
			
			In JSF:
			I can call a JSP page like
http://...faces/JSP/Example.jsp but there is a way to call a backing
bean before show the JSP?
			
			I need to do something in the backing bean (set
some variables, etc) before showing the jsp, but I dont know if this is
posible in JSF. 
			
			thanks




Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Sorry, this is the correct question, I have a mistake on the App # :P

Let me explain better my case, I have an App1 and App2, they are in
different servers, App1 have a link to call the App2, but I need do some
things before show the index of the App*2*, actually the link calls directly
the index.jsp of the App*2*, In this case I only need the listener for do
things when the App1 calls App2, something like in the onload of the App2.
Can I use a listener when a specific JSP is show? Can I call directly the
backing bean?

thanks again

On Jan 7, 2008 3:26 PM, daniel ccss <da...@gmail.com> wrote:

> Thanks for the answers, I used a phaselistener but is for all the
> application, like the one in the example of the login:
>
>  <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
> </phase-listener>
> but this type of listener is call for every Bean and my case is different.
>
> Let me explain better my case, I have an App1 and App2, they are in
> different servers, App1 have a link to call the App2, but I need do some
> things before show the index of the App*2*, actually the link calls
> directly the index.jsp of the App*2*, In this case I only need the
> listener for do things when the App1 calls App2, something like in the
> onload of the App2. Can I use a listener when a specific JSP is show? Can I
> call directly the backing bean?
>
> thanks
>
>
>
> On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:
>
> > Can you do it in Spring?
> >
> > John
> >
> >
> > At 12:24 PM 1/7/2008, you wrote:
> >
> > Hi all,
> >
> > In struts:
> > I can call a JSP page like http://..../JSP/Example.jsp and I also can
> > call an action that do something and then do the forward to the
> > Example.jsp like this: http:// <http:///> .../Example*.do
> > *
> > In JSF:
> > I can call a JSP page like http://...faces/JSP/Example.jsp *but *there
> > is a way to call a backing bean before show the JSP?
> >
> > I need to do something in the backing bean (set some variables, etc)
> > before showing the jsp, but I dont know if this is posible in JSF.
> >
> > thanks
> >
> >
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Thanks for the answers, I used a phaselistener but is for all the
application, like the one in the example of the login:

 <phase-listener>com.loffler.copycenter.controller.LoggedInCheck
</phase-listener>
but this type of listener is call for every Bean and my case is different.

Let me explain better my case, I have an App1 and App2, they are in
different servers, App1 have a link to call the App2, but I need do some
things before show the index of the App1, actually the link calls directly
the index.jsp of the App1, In this case I only need the listener for do
things when the App1 calls App2, something like in the onload of the app2.
Can I use a listener when a specific JSP is show? Can I call directly the
backing bean?

thanks



On Jan 7, 2008 2:53 PM, John Carlson <ca...@llnl.gov> wrote:

> Can you do it in Spring?
>
> John
>
>
> At 12:24 PM 1/7/2008, you wrote:
>
> Hi all,
>
> In struts:
> I can call a JSP page like http://..../JSP/Example.jsp and I also can call
> an action that do something and then do the forward to the Example.jsplike this:
> http:// <http:///> .../Example*.do
> *
> In JSF:
> I can call a JSP page like http://...faces/JSP/Example.jsp *but *there is
> a way to call a backing bean before show the JSP?
>
> I need to do something in the backing bean (set some variables, etc)
> before showing the jsp, but I dont know if this is posible in JSF.
>
> thanks
>
>

Re: Call a backing bean before show a JSP

Posted by daniel ccss <da...@gmail.com>.
Thanks, not in ths proyect we don´t use spring

On Jan 7, 2008 2:58 PM, John Carlson <ca...@llnl.gov> wrote:

> See:
>
> org.springframework.web.jsf.DelegatingVariableResolver
>
> John
>
>
> At 12:53 PM 1/7/2008, John Carlson wrote:
>
> Can you do it in Spring?
>
> John
>
> At 12:24 PM 1/7/2008, you wrote:
>
> Hi all,
>
> In struts:
> I can call a JSP page like http://..../JSP/Example.jsp and I also can call
> an action that do something and then do the forward to the Example.jsplike this:
> http:// <http:///> .../Example*.do
> *
> In JSF:
> I can call a JSP page like http://...faces/JSP/Example.jsp *but *there is
> a way to call a backing bean before show the JSP?
>
> I need to do something in the backing bean (set some variables, etc)
> before showing the jsp, but I dont know if this is posible in JSF.
>
> thanks
>
>