You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bruno Aranda <br...@gmail.com> on 2005/06/17 12:23:25 UTC
Re: How can I avoid using the jsp:useBean tag?
Maybe you could create a list with your properties (invoking your
setup method before adding the property to the list), and the usint a
dataTable or dataList to show the properties... This should work and
is more elegant ;-)
Regards,
Bruno
2005/6/17, Randahl Fink Isaksen <ra...@rockit.dk>:
> In my faces-config I have defined a bean called myBean and I have a trivial
> statement like this in my jspx file:
>
> <h:outputText value="#{myBean.myProperty}"/>
>
> However this statement is placed inside a loop and at the start of each
> iteration I need to call a method called myBean.setup() before I try to get
> any properties. Because I have not found any better way, I am doing the
> following at the start of each iteration:
>
> <jsp:useBean
> id="myBean"
> class="dk.rockit.x.y.z.MyBean"
> scope="request"
> />
> <jsp:scriptlet>myBean.setup();</jsp:scriptlet>
>
> I dislike this approach for several reasons:
>
>
> Above I bind my bean to a variable directly in the jspx page - if the class
> name changes I need to manually find all the useBean tags in all my files
> and change them. Of course I would prefer to simply define the beans in
> faces-config.xml - that way I would only have one file to edit when a class
> name changed.
> It does not feel very JSF-like I think - I was hoping for something more
> along the lines of a tag that looked like <f:invoke
> method="myBean.setup()"/>
> In general I think the less the code scriptlets the better. Has anyone come
> up with a way to get arround the jsp:useBean tag? Apart from defining your
> own x:invoke tag like above ;-)
>
>
> Randahl
>
>
>