You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gr...@intellicare.com on 2006/02/10 21:35:43 UTC

{shale] Backing bean (prerender) functionality in buttons on a tile

Thanks for reading my note.

I have a Shale/MyFaces/ app which i have been using with Tiles. I have 
pages home.jsp, search.jsp etc. And since the recommended method is to 
have one backing bean per jsp, I have corresponding HomeBean, SearchBean, 
etc. and everything works quite nicely.

But now I have a new requirement: on the "menu" tile on the left nav bar I 
have to place a  very simple version of a "soft phone": a text field to 
enter a phone number, button to click "dial", text field to enter another 
number, button to click "Transfer", "Conference" etc.

Now since this phone will essentially appear in every page of my 
application, how would I code for the buttons in menu.jsp? I mean what 
action should I point it to, since the "backing bean" will be different 
depending on whether I am on say "home.faces or "search.faces" etc..?

What I did initially was to make a new backing bean called PhoneBean 
extending AbstractViewController) and simply coded the actions as pointing 
to phone.dial, phone.transfer etc and much to my surprise it worked! But 
here's the catch: now I need to add some code to the phone.prerender() 
method and alas! this method is never being called - and I guess this must 
be because the PhoneBean is not *really* the backing bean to home.faces, 
search.faces, etc.. I can think of cludgy ways to get round this, but I am 
hoping somebody will show me the error of my ways..? Perhaps there is a 
way to include one jsf within another each with its own backing bean so 
that both will get their prerender methods executed..?

Thanks again,
Geeta

Re: {shale] Backing bean (prerender) functionality in buttons on a tile

Posted by gr...@intellicare.com.
gramani@intellicare.com wrote on 02/10/2006 04:54:15 PM:

> craigmcc@gmail.com wrote on 02/10/2006 03:58:11 PM:
> 
> > 
> > I would clarify this "recommended method" to have one backing bean per
> > *Tile* not just for the whole page.  That sounds pretty much like what 

> you
> > did below.
> > 
> 
> Ah, I didn't know that! Ok, so my app certainly doesn't follow this 
rule, 
> but somehow I guess it is somehow bumbling along.. I will have to go 
back 
> and fix that, but first..
> 
> > 
> > On the outer JSP page, did you include each Tile inside an 
<s:subview>?
> 
> No, I didn't have this, so i added it, but according to the tld I have 
to 
> add an id to this tag.  What should I use? I googled and the 
> recommendation was to use the same name as the tile attribute. I don't 
> think this is right since I get the foll. warning:
> [WARN] Subview - No managed bean for subview menu
> 

Never mind; I renamed the managed bean name in faces-config to "menu" and 
the subview id in layout.jsp to "menu" and now the prerender is indeed 
being called in both outer and inner backing beans..:) Thank you very much 
for the pointer, Craig - this is certainly a nice solution..:)

Geeta

Re: {shale] Backing bean (prerender) functionality in buttons on a tile

Posted by gr...@intellicare.com.
craigmcc@gmail.com wrote on 02/10/2006 03:58:11 PM:

> 
> I would clarify this "recommended method" to have one backing bean per
> *Tile* not just for the whole page.  That sounds pretty much like what 
you
> did below.
> 

Ah, I didn't know that! Ok, so my app certainly doesn't follow this rule, 
but somehow I guess it is somehow bumbling along.. I will have to go back 
and fix that, but first..

> 
> On the outer JSP page, did you include each Tile inside an <s:subview>?

No, I didn't have this, so i added it, but according to the tld I have to 
add an id to this tag.  What should I use? I googled and the 
recommendation was to use the same name as the tile attribute. I don't 
think this is right since I get the foll. warning:
[WARN] Subview - No managed bean for subview menu

If all this is already documented elsewhere please do give me the link.. 
Otherwise, if you could bear to read on, here's a snippet from my 
layout.jsp:

<h:panelGrid columns="3" width="780" columnClasses=
"pageNavigation,td,pageBody">
        <h:panelGrid columns="1" columnClasses="pageNavigation" >
        <s:subview id="menu">
                <tiles:insert attribute="menu" flush="false" />
        </s:subview>
</h:panelGrid>


My faces-config.xml has this:

<managed-bean>
        <managed-bean-name>phone</managed-bean-name>
        <managed-bean-class>
                com.intellicare.webshark.action.phone.PhoneBean
        </managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

(Btw, changing the above to:
<managed-bean-name>layout$menu</managed-bean-name>
didn't make any differnce either..)

my tiles.xml has for example:
<definition name="/home" path="/layout/layout.jsp">
          <put name="title" value="Intellicare, Inc. - Home" />
          <put name="header" value="/layout/headerWelcomeAgent.jsp" />
          <put name="menu" value="/layout/menu.jsp" />
          <put name="body" value="/homeBody.jsp"/>
   </definition>



> That is the place where you are supposed to get the view controller
> callbacks for the backing bean for each individual tile.  If that 
doesn't
> work, please file a bug ... it is supposed to.

I think if I got the subview id right this will probably work..:)

> 
> Craig
> 

Many thanks again!
Geeta

Re: {shale] Backing bean (prerender) functionality in buttons on a tile

Posted by Craig McClanahan <cr...@apache.org>.
On 2/10/06, gramani@intellicare.com <gr...@intellicare.com> wrote:
>
> Thanks for reading my note.
>
> I have a Shale/MyFaces/ app which i have been using with Tiles. I have
> pages home.jsp, search.jsp etc. And since the recommended method is to
> have one backing bean per jsp, I have corresponding HomeBean, SearchBean,
> etc. and everything works quite nicely.


I would clarify this "recommended method" to have one backing bean per
*Tile* not just for the whole page.  That sounds pretty much like what you
did below.

But now I have a new requirement: on the "menu" tile on the left nav bar I
> have to place a  very simple version of a "soft phone": a text field to
> enter a phone number, button to click "dial", text field to enter another
> number, button to click "Transfer", "Conference" etc.
>
> Now since this phone will essentially appear in every page of my
> application, how would I code for the buttons in menu.jsp? I mean what
> action should I point it to, since the "backing bean" will be different
> depending on whether I am on say "home.faces or "search.faces" etc..?
>
> What I did initially was to make a new backing bean called PhoneBean
> extending AbstractViewController) and simply coded the actions as pointing
> to phone.dial, phone.transfer etc and much to my surprise it worked! But
> here's the catch: now I need to add some code to the phone.prerender()
> method and alas! this method is never being called - and I guess this must
> be because the PhoneBean is not *really* the backing bean to home.faces,
> search.faces, etc.. I can think of cludgy ways to get round this, but I am
> hoping somebody will show me the error of my ways..? Perhaps there is a
> way to include one jsf within another each with its own backing bean so
> that both will get their prerender methods executed..?


On the outer JSP page, did you include each Tile inside an <s:subview>?
That is the place where you are supposed to get the view controller
callbacks for the backing bean for each individual tile.  If that doesn't
work, please file a bug ... it is supposed to.

Thanks again,
> Geeta
>

Craig