You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mfaine <mf...@knology.net> on 2004/12/09 20:12:39 UTC

pass bean as parameter to JSP

If I have several beans (in a collection)  that are all of the same type and
I would like to allow the user to click a button to go to a page that would
allow editing the fields of this bean.  How do I pass the bean as a
parameter.  IOW, how do I dynamically wire a bean to a JSP page?

Thanks,
-Mark


Re: pass bean as parameter to JSP

Posted by Hendrik Neumann <he...@web.de>.
hhmm... than I'll have to re-write my code. good that we straightened out my 
misconceptions at a early stage of development, because I have just started 
writing the JSF-Code for my project three days ago

Am Freitag, 10. Dezember 2004 17:43 schrieb David Geary:
> Le Dec 10, 2004, à 9:42 AM, Matthias Wessendorf a écrit :
> > David,
> >
> >> As Matthias points out below, you cannot use JSF html tags inside of
> >> c:forEach. That's not only bad style, but it won't work as
> >> you expect,
> >> at least until JSF 1.2.
> >
> > I guess you are inside of JCP-JSF-Group, isn't it?
> > So my question:
> > -JSF 1.2 will be included into J2EE 1.5 (aka J2EE 5)?
>
> I don't know when JSF 1.2 will be ready, but containers that support
> J2EE 1.5 must supply a JSF implementation.

Re: pass bean as parameter to JSP

Posted by David Geary <sa...@earthlink.net>.
Le Dec 10, 2004, à 9:42 AM, Matthias Wessendorf a écrit :

> David,
>
>> As Matthias points out below, you cannot use JSF html tags inside of
>> c:forEach. That's not only bad style, but it won't work as
>> you expect,
>> at least until JSF 1.2.
>
> I guess you are inside of JCP-JSF-Group, isn't it?
> So my question:
> -JSF 1.2 will be included into J2EE 1.5 (aka J2EE 5)?

I don't know when JSF 1.2 will be ready, but containers that support 
J2EE 1.5 must supply a JSF implementation.


david
>
> thanks,
> Matthias
>
>> david geary
>>
>>> Btw. looked at Oracle's ADF Faces?
>>>
>>> <af:forEach/> will enable you to do things like
>>> this in *good old* jsf-manner
>>>
>>> :)
>>>
>>>
>>>> <c:forEach var="myVar" items="${myComp.myVectors}">
>>>>  <c:set value="${myVar}"
>> var="myVarAsManagedBeanDefinedInFacesConfig"
>>>> scope="myScope" />
>>>>  <h:outputText
>>>> value="#{myVarAsManagedBeanDefinedInFacesConfig.foo}"/>
>>>>
>>>> <managed-bean>
>>>> <managed-bean-name>myVarAsManagedBeanDefinedInFacesConfig</man
>>>> aged-bean-name>
>>>> <managed-bean-class>ClassOfMyVar</managed-bean-class>
>>>> <managed-bean-scope>myScope</managed-bean-scope>
>>>> </managed-bean>
>>>>
>>>> works without any problems :-)
>>>>
>>>> Regards,
>>>> Hendrik
>>>>
>>>> Am Freitag, 10. Dezember 2004 07:38 schrieb Matthias Wessendorf:
>>>>> Hendrik,
>>>>>
>>>>> Heath means that you can't do things like:
>>>>>
>>>>> <c:forEach var="myVar" items="${myComp.myVectors}"> <h:outputText
>>>>> value="#{myVar.foo}"/> ... </c:...>
>>>>>
>>>>> Hans Bergsten wroten a nice article
>>>>> on that (and other things):
>>>>> http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
>>>>>
>>>>> Regards,
>>>>> Matthias
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de]
>>>>>> Sent: Friday, December 10, 2004 7:24 AM
>>>>>> To: MyFaces Discussion
>>>>>> Subject: Re: pass bean as parameter to JSP
>>>>>>
>>>>>> Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
>>>>>>> I don't think you can use JSF tags inside a JSTL forEach tag.
>>>>>>
>>>>>> A managed bean specified in the faces-config is - afaik -
>>>> a more or
>>>>>> less normal jsp bean, reachable for all JSTL Tags, therefore you
>>>>>> can do this (let's say myComp is a managed bean, specified in the
>>>> faces-config):
>>>>>>
>>>>>> <c:forEach var="myVar" items="${myComp.myVectors}">
>>>>>> <c:set value="${myVar.hashCode}" target="${tempBean}"
>>>>>> property="tempHashValue" />
>>>>>>
>>>>>> If you're instancing objects with the c:forEach-Tag and
>>>> want to use
>>>>>> one of them as a managed bean (to do value binding etc.)
>>>> you'll need
>>>>>> to set reference correct:
>>>>>>
>>>>>> <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
>>>>>> scope="myScope" />
>>>>>>
>>>>>> Mabe it is not 100% standard conformable but belive me it
>>>> works -
>>>>>> I'm doing exactly this in my project with your MyFaces without
>>>>>> having any troubles.
>>>>>>
>>>>>> Greetings,
>>>>>> Hendrik
>>>>
>>>
>>
>


Re: pass bean as parameter to JSP

Posted by Matt Raible <li...@raibledesigns.com>.
Matthias Wessendorf wrote:

>David,
>
>  
>
>>As Matthias points out below, you cannot use JSF html tags inside of 
>>c:forEach. That's not only bad style, but it won't work as 
>>you expect, 
>>at least until JSF 1.2.
>>    
>>
>
>I guess you are inside of JCP-JSF-Group, isn't it?
>So my question:
>-JSF 1.2 will be included into J2EE 1.5 (aka J2EE 5)?
>  
>

Yep.


RE: pass bean as parameter to JSP

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
David,

> As Matthias points out below, you cannot use JSF html tags inside of 
> c:forEach. That's not only bad style, but it won't work as 
> you expect, 
> at least until JSF 1.2.

I guess you are inside of JCP-JSF-Group, isn't it?
So my question:
-JSF 1.2 will be included into J2EE 1.5 (aka J2EE 5)?

thanks,
Matthias

> david geary
> 
> > Btw. looked at Oracle's ADF Faces?
> >
> > <af:forEach/> will enable you to do things like
> > this in *good old* jsf-manner
> >
> > :)
> >
> >
> >> <c:forEach var="myVar" items="${myComp.myVectors}">
> >>  <c:set value="${myVar}" 
> var="myVarAsManagedBeanDefinedInFacesConfig"
> >> scope="myScope" />
> >>  <h:outputText 
> >> value="#{myVarAsManagedBeanDefinedInFacesConfig.foo}"/>
> >>
> >> <managed-bean> 
> >> <managed-bean-name>myVarAsManagedBeanDefinedInFacesConfig</man
> >> aged-bean-name>
> >> <managed-bean-class>ClassOfMyVar</managed-bean-class>
> >> <managed-bean-scope>myScope</managed-bean-scope>
> >> </managed-bean>
> >>
> >> works without any problems :-)
> >>
> >> Regards,
> >> Hendrik
> >>
> >> Am Freitag, 10. Dezember 2004 07:38 schrieb Matthias Wessendorf:
> >>> Hendrik,
> >>>
> >>> Heath means that you can't do things like:
> >>>
> >>> <c:forEach var="myVar" items="${myComp.myVectors}"> <h:outputText 
> >>> value="#{myVar.foo}"/> ... </c:...>
> >>>
> >>> Hans Bergsten wroten a nice article
> >>> on that (and other things): 
> >>> http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
> >>>
> >>> Regards,
> >>> Matthias
> >>>
> >>>> -----Original Message-----
> >>>> From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de]
> >>>> Sent: Friday, December 10, 2004 7:24 AM
> >>>> To: MyFaces Discussion
> >>>> Subject: Re: pass bean as parameter to JSP
> >>>>
> >>>> Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
> >>>>> I don't think you can use JSF tags inside a JSTL forEach tag.
> >>>>
> >>>> A managed bean specified in the faces-config is - afaik -
> >> a more or
> >>>> less normal jsp bean, reachable for all JSTL Tags, therefore you 
> >>>> can do this (let's say myComp is a managed bean, specified in the
> >> faces-config):
> >>>>
> >>>> <c:forEach var="myVar" items="${myComp.myVectors}">
> >>>> <c:set value="${myVar.hashCode}" target="${tempBean}" 
> >>>> property="tempHashValue" />
> >>>>
> >>>> If you're instancing objects with the c:forEach-Tag and
> >> want to use
> >>>> one of them as a managed bean (to do value binding etc.)
> >> you'll need
> >>>> to set reference correct:
> >>>>
> >>>> <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
> >>>> scope="myScope" />
> >>>>
> >>>> Mabe it is not 100% standard conformable but belive me it
> >> works -
> >>>> I'm doing exactly this in my project with your MyFaces without 
> >>>> having any troubles.
> >>>>
> >>>> Greetings,
> >>>> Hendrik
> >>
> >
> 


Re: pass bean as parameter to JSP

Posted by David Geary <sa...@earthlink.net>.
Le Dec 10, 2004, à 12:48 AM, Matthias Wessendorf a écrit :

>
>> maybe it is not good JSF-Style but it definitely works! Of
>> course you'll have
>> to set the reference of "myVar" to managed JSF-Bean like this
>> (if you don't
>> do this, it will not work):
>
> yes, I would say, this is not good JSF-Style...

There's nothing wrong with accessing JSF managed beans with JSTL tags. 
Managed beans differ from "regular beans" only in the manner in which 
they are constructed and initialized; otherwise, they are simply scoped 
variables.

As Matthias points out below, you cannot use JSF html tags inside of 
c:forEach. That's not only bad style, but it won't work as you expect, 
at least until JSF 1.2.


david geary

> Btw. looked at Oracle's ADF Faces?
>
> <af:forEach/> will enable you to do things like
> this in *good old* jsf-manner
>
> :)
>
>
>> <c:forEach var="myVar" items="${myComp.myVectors}">
>>  <c:set value="${myVar}" var="myVarAsManagedBeanDefinedInFacesConfig"
>> scope="myScope" />
>>  <h:outputText value="#{myVarAsManagedBeanDefinedInFacesConfig.foo}"/>
>>
>> <managed-bean>
>> <managed-bean-name>myVarAsManagedBeanDefinedInFacesConfig</man
>> aged-bean-name>
>> <managed-bean-class>ClassOfMyVar</managed-bean-class>
>> <managed-bean-scope>myScope</managed-bean-scope>
>> </managed-bean>
>>
>> works without any problems :-)
>>
>> Regards,
>> Hendrik
>>
>> Am Freitag, 10. Dezember 2004 07:38 schrieb Matthias Wessendorf:
>>> Hendrik,
>>>
>>> Heath means that you can't do things like:
>>>
>>> <c:forEach var="myVar" items="${myComp.myVectors}"> <h:outputText
>>> value="#{myVar.foo}"/> ...
>>> </c:...>
>>>
>>> Hans Bergsten wroten a nice article
>>> on that (and other things):
>>> http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
>>>
>>> Regards,
>>> Matthias
>>>
>>>> -----Original Message-----
>>>> From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de]
>>>> Sent: Friday, December 10, 2004 7:24 AM
>>>> To: MyFaces Discussion
>>>> Subject: Re: pass bean as parameter to JSP
>>>>
>>>> Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
>>>>> I don't think you can use JSF tags inside a JSTL forEach tag.
>>>>
>>>> A managed bean specified in the faces-config is - afaik -
>> a more or
>>>> less normal jsp bean, reachable for all JSTL Tags, therefore you
>>>> can do this
>>>> (let's say myComp is a managed bean, specified in the
>> faces-config):
>>>>
>>>> <c:forEach var="myVar" items="${myComp.myVectors}">
>>>> <c:set value="${myVar.hashCode}" target="${tempBean}"
>>>> property="tempHashValue" />
>>>>
>>>> If you're instancing objects with the c:forEach-Tag and
>> want to use
>>>> one of them as a managed bean (to do value binding etc.)
>> you'll need
>>>> to set reference correct:
>>>>
>>>> <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
>>>> scope="myScope" />
>>>>
>>>> Mabe it is not 100% standard conformable but belive me it
>> works -
>>>> I'm doing exactly this in my project with your MyFaces without
>>>> having any troubles.
>>>>
>>>> Greetings,
>>>> Hendrik
>>
>


RE: pass bean as parameter to JSP

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
> maybe it is not good JSF-Style but it definitely works! Of 
> course you'll have 
> to set the reference of "myVar" to managed JSF-Bean like this 
> (if you don't 
> do this, it will not work):

yes, I would say, this is not good JSF-Style...
Btw. looked at Oracle's ADF Faces?

<af:forEach/> will enable you to do things like
this in *good old* jsf-manner 

:)


> <c:forEach var="myVar" items="${myComp.myVectors}">
>  <c:set value="${myVar}" var="myVarAsManagedBeanDefinedInFacesConfig" 
> scope="myScope" />
>  <h:outputText value="#{myVarAsManagedBeanDefinedInFacesConfig.foo}"/>
> 
> <managed-bean> 
> <managed-bean-name>myVarAsManagedBeanDefinedInFacesConfig</man
> aged-bean-name>  
> <managed-bean-class>ClassOfMyVar</managed-bean-class>
> <managed-bean-scope>myScope</managed-bean-scope>
> </managed-bean>
> 
> works without any problems :-)
> 
> Regards,
> Hendrik
> 
> Am Freitag, 10. Dezember 2004 07:38 schrieb Matthias Wessendorf:
> > Hendrik,
> >
> > Heath means that you can't do things like:
> >
> > <c:forEach var="myVar" items="${myComp.myVectors}"> <h:outputText 
> > value="#{myVar.foo}"/> ...
> > </c:...>
> >
> > Hans Bergsten wroten a nice article
> > on that (and other things): 
> > http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
> >
> > Regards,
> > Matthias
> >
> > > -----Original Message-----
> > > From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de]
> > > Sent: Friday, December 10, 2004 7:24 AM
> > > To: MyFaces Discussion
> > > Subject: Re: pass bean as parameter to JSP
> > >
> > > Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
> > > > I don't think you can use JSF tags inside a JSTL forEach tag.
> > >
> > > A managed bean specified in the faces-config is - afaik - 
> a more or 
> > > less normal jsp bean, reachable for all JSTL Tags, therefore you
> > > can do this
> > > (let's say myComp is a managed bean, specified in the 
> faces-config):
> > >
> > > <c:forEach var="myVar" items="${myComp.myVectors}">
> > > <c:set value="${myVar.hashCode}" target="${tempBean}" 
> > > property="tempHashValue" />
> > >
> > > If you're instancing objects with the c:forEach-Tag and 
> want to use 
> > > one of them as a managed bean (to do value binding etc.) 
> you'll need 
> > > to set reference correct:
> > >
> > > <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
> > > scope="myScope" />
> > >
> > > Mabe it is not 100% standard conformable but belive me it 
> works -  
> > > I'm doing exactly this in my project with your MyFaces without 
> > > having any troubles.
> > >
> > > Greetings,
> > > Hendrik
> 


Re: pass bean as parameter to JSP

Posted by Hendrik Neumann <he...@web.de>.
maybe it is not good JSF-Style but it definitely works! Of course you'll have 
to set the reference of "myVar" to managed JSF-Bean like this (if you don't 
do this, it will not work):

<c:forEach var="myVar" items="${myComp.myVectors}">
 <c:set value="${myVar}" var="myVarAsManagedBeanDefinedInFacesConfig" 
scope="myScope" />
 <h:outputText value="#{myVarAsManagedBeanDefinedInFacesConfig.foo}"/>

<managed-bean>
<managed-bean-name>myVarAsManagedBeanDefinedInFacesConfig</managed-bean-name>  
<managed-bean-class>ClassOfMyVar</managed-bean-class>
<managed-bean-scope>myScope</managed-bean-scope>
</managed-bean>

works without any problems :-)

Regards,
Hendrik

Am Freitag, 10. Dezember 2004 07:38 schrieb Matthias Wessendorf:
> Hendrik,
>
> Heath means that you can't do things like:
>
> <c:forEach var="myVar" items="${myComp.myVectors}">
> <h:outputText value="#{myVar.foo}"/>
> ...
> </c:...>
>
> Hans Bergsten wroten a nice article
> on that (and other things):
> http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html
>
> Regards,
> Matthias
>
> > -----Original Message-----
> > From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de]
> > Sent: Friday, December 10, 2004 7:24 AM
> > To: MyFaces Discussion
> > Subject: Re: pass bean as parameter to JSP
> >
> > Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
> > > I don't think you can use JSF tags inside a JSTL forEach tag.
> >
> > A managed bean specified in the faces-config is - afaik - a
> > more or less
> > normal jsp bean, reachable for all JSTL Tags, therefore you
> > can do this
> > (let's say myComp is a managed bean, specified in the faces-config):
> >
> > <c:forEach var="myVar" items="${myComp.myVectors}">
> > <c:set value="${myVar.hashCode}" target="${tempBean}"
> > property="tempHashValue" />
> >
> > If you're instancing objects with the c:forEach-Tag and want
> > to use one of
> > them as a managed bean (to do value binding etc.) you'll need to set
> > reference correct:
> >
> > <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
> > scope="myScope" />
> >
> > Mabe it is not 100% standard conformable but belive me it
> > works -  I'm doing
> > exactly this in my project with your MyFaces without having
> > any troubles.
> >
> > Greetings,
> > Hendrik

RE: pass bean as parameter to JSP

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hendrik,

Heath means that you can't do things like:

<c:forEach var="myVar" items="${myComp.myVectors}">
<h:outputText value="#{myVar.foo}"/>
...
</c:...>

Hans Bergsten wroten a nice article
on that (and other things):
http://www.onjava.com/pub/a/onjava/2004/06/09/jsf.html

Regards,
Matthias


> -----Original Message-----
> From: hendrik-neumann@web.de [mailto:hendrik-neumann@web.de] 
> Sent: Friday, December 10, 2004 7:24 AM
> To: MyFaces Discussion
> Subject: Re: pass bean as parameter to JSP
> 
> 
> Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
> > I don't think you can use JSF tags inside a JSTL forEach tag.
> 
> A managed bean specified in the faces-config is - afaik - a 
> more or less 
> normal jsp bean, reachable for all JSTL Tags, therefore you 
> can do this 
> (let's say myComp is a managed bean, specified in the faces-config):
> 
> <c:forEach var="myVar" items="${myComp.myVectors}">
> <c:set value="${myVar.hashCode}" target="${tempBean}" 
> property="tempHashValue" />
> 
> If you're instancing objects with the c:forEach-Tag and want 
> to use one of 
> them as a managed bean (to do value binding etc.) you'll need to set 
> reference correct:
> 
> <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
> scope="myScope" />
> 
> Mabe it is not 100% standard conformable but belive me it 
> works -  I'm doing 
> exactly this in my project with your MyFaces without having 
> any troubles.
> 
> Greetings, 
> Hendrik
> 


Re: pass bean as parameter to JSP

Posted by Hendrik Neumann <he...@web.de>.
Am Donnerstag, 9. Dezember 2004 22:40 schrieb Heath Borders:
> I don't think you can use JSF tags inside a JSTL forEach tag.

A managed bean specified in the faces-config is - afaik - a more or less 
normal jsp bean, reachable for all JSTL Tags, therefore you can do this 
(let's say myComp is a managed bean, specified in the faces-config):

<c:forEach var="myVar" items="${myComp.myVectors}">
<c:set value="${myVar.hashCode}" target="${tempBean}"
property="tempHashValue" />

If you're instancing objects with the c:forEach-Tag and want to use one of 
them as a managed bean (to do value binding etc.) you'll need to set 
reference correct:

<c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
scope="myScope" />

Mabe it is not 100% standard conformable but belive me it works -  I'm doing 
exactly this in my project with your MyFaces without having any troubles.

Greetings, 
Hendrik

RE: pass bean as parameter to JSP

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Heath,
yes, right. Even JSF 1.2 says that you can't use them inside!
"JSF component custom actions may NOT be nested inside a custom action
that iterates over
its body (such as JSTL's <c:forEach>). Instead, you should use a
Renderer that performs
its own iteration (such as the Table renderer used by <h:dataTable>)."


Mark, what you can do is: (#{members} is your collection, containing
your objects...)

<h:dataTable value="#{members}" var="member">
 <h:column> 
  <f:facet name="header"> 
      <h:outputText value="Name"/> 
    </f:facet> 
    <h:outputText value="#{member.name}"/> 
  </h:column> 
...
<h:column>
  <h:outputLink value="edit.jsf">
  <h:outputText value="edit this member"/>
  <f:param name="id" value="#{member.uniqueId}"/> 
  </h:outputLink>
  </h:column>
</h:dataTable>


inside of edit.jsf you got a form (backed to a bean)

The Bean (backed to edit,jsp) could have a constructor like this:

  BackingBeanForEditing(){

 String param = (String)
FacesContext.getCurrentInstance().getExternalContext().getRequestParamet
erMap().get("uniqueId");
 
if(param!=null){

	MyCustomObject mco = backend.loadMyObjectByCriteria(param);
}
...
    
 } 

scope for the Backingbean for edit.jsp should be "request"

Btw. I have an example WAR, if you need...
(with dummy values no backend is needed... ;-))

HTH,
Matthias


> -----Original Message-----
> From: Heath Borders [mailto:heath.borders@gmail.com] 
> Sent: Thursday, December 09, 2004 10:41 PM
> To: MyFaces Discussion
> Subject: Re: pass bean as parameter to JSP
> 
> 
> I don't think you can use JSF tags inside a JSTL forEach tag.
> 
> 
> On Thu, 9 Dec 2004 22:38:07 +0100, Hendrik Neumann 
> <he...@web.de> wrote:
> > you could do this (using JSTL, the hash code and a special
> > hashCode-get-Method):
> > 
> > <c:forEach var="myVar" items="${myComp.myVectors}">
> > <c:set value="${myVar.hashCode}" target="${tempBean}" 
> > property="tempHashValue" />
> > 
> > <h:commandLink action="setHashCode">
> > <h:graphicImage url="myIcon.gif" />
> > <f:param name="hashCode" value="#{tempBean.tempHashValue}" /> 
> > </h:commandLink>
> > 
> > [...]
> > 
> > (you must define the method public String getHashCode(return 
> > hashCode;))
> > 
> > In the result.jsf you will need to find the needed 
> component and load 
> > it int the scope:
> > 
> > <c:forEach var="myVar" items="${myComp.myVectors}">
> > <c:if test="${myVar.hashCode == tempBean.tempHashValue}"> <c:set 
> > value="${myVar}" var="managedBeanDefinedInFacesConfig"
> > scope="myScope" />
> > [...]
> > 
> > If you want to access the http-parameter themselfs in a 
> managed bean, 
> > do this:
> > 
> > ApplicationFactory factory = (ApplicationFactory)
> > FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
> > Application application = factory.getApplication(); ValueBinding 
> > binding = null; FacesContext context = 
> > FacesContext.getCurrentInstance();
> > binding = application.createValueBinding("#{param.myParamName}");
> > System.out.println(binding.getValue(context));
> > 
> 
> 
> -- 
> If you don't have a GMail account, I probably have 5 invites. 
>  Just ask! -Heath Borders-Wing hborders@mail.win.org
> 


Re: pass bean as parameter to JSP

Posted by Heath Borders <he...@gmail.com>.
I don't think you can use JSF tags inside a JSTL forEach tag.


On Thu, 9 Dec 2004 22:38:07 +0100, Hendrik Neumann
<he...@web.de> wrote:
> you could do this (using JSTL, the hash code and a special
> hashCode-get-Method):
> 
> <c:forEach var="myVar" items="${myComp.myVectors}">
> <c:set value="${myVar.hashCode}" target="${tempBean}"
> property="tempHashValue" />
> 
> <h:commandLink action="setHashCode">
> <h:graphicImage url="myIcon.gif" />
> <f:param name="hashCode" value="#{tempBean.tempHashValue}" />
> </h:commandLink>
> 
> [...]
> 
> (you must define the method public String getHashCode(return hashCode;))
> 
> In the result.jsf you will need to find the needed component and load it int
> the scope:
> 
> <c:forEach var="myVar" items="${myComp.myVectors}">
> <c:if test="${myVar.hashCode == tempBean.tempHashValue}">
> <c:set value="${myVar}" var="managedBeanDefinedInFacesConfig"
> scope="myScope" />
> [...]
> 
> If you want to access the http-parameter themselfs in a managed bean, do this:
> 
> ApplicationFactory factory = (ApplicationFactory)
> FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
> Application application = factory.getApplication();
> ValueBinding binding = null;
> FacesContext context = FacesContext.getCurrentInstance();
> binding = application.createValueBinding("#{param.myParamName}");
> System.out.println(binding.getValue(context));
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: pass bean as parameter to JSP

Posted by Hendrik Neumann <he...@web.de>.
you could do this (using JSTL, the hash code and a special 
hashCode-get-Method):

<c:forEach var="myVar" items="${myComp.myVectors}">
<c:set value="${myVar.hashCode}" target="${tempBean}" 
property="tempHashValue" />

<h:commandLink action="setHashCode">
 <h:graphicImage url="myIcon.gif" />
 <f:param name="hashCode" value="#{tempBean.tempHashValue}" />
</h:commandLink>

[...]

(you must define the method public String getHashCode(return hashCode;))

In the result.jsf you will need to find the needed component and load it int 
the scope:

<c:forEach var="myVar" items="${myComp.myVectors}">
<c:if test="${myVar.hashCode == tempBean.tempHashValue}">
<c:set value="${myVar}" var="managedBeanDefinedInFacesConfig" 
scope="myScope" />
[...]


If you want to access the http-parameter themselfs in a managed bean, do this:

ApplicationFactory factory = (ApplicationFactory) 
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
ValueBinding binding = null;
FacesContext context = FacesContext.getCurrentInstance();
binding = application.createValueBinding("#{param.myParamName}");
System.out.println(binding.getValue(context));

Re: pass bean as parameter to JSP

Posted by Heath Borders <he...@gmail.com>.
You could set up a dummy managed bean of that type for your jsp, and
then set the value of that dummy bean to the bean the user selected
using:

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("dummyBeanName",
dummyBean);

This, of course, is assuming that your bean is session-scoped.


On 9 Dec 2004 19:12:39 -0000, mfaine <mf...@knology.net> wrote:
> If I have several beans (in a collection)  that are all of the same type and
> I would like to allow the user to click a button to go to a page that would
> allow editing the fields of this bean.  How do I pass the bean as a
> parameter.  IOW, how do I dynamically wire a bean to a JSP page?
> 
> Thanks,
> -Mark
> 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org