You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Costa Basil <co...@yahoo.ca> on 2006/03/10 19:24:41 UTC

how to detect in the backing bean (the shale viewcontroller) that the user navigates to another page?

I use shale and I was wondering if there is there an easy way to know in a backing bean on the postback that the user actually pressed a commandLink that navigates to another page than the one the backing bean is for. I want to avoid unecessary database calls. 


Thanks
		
---------------------------------
Enrich your life at Yahoo! Canada Finance

Coding in JSP page

Posted by sj...@stradefi.com.
Hi !

 

Could somebody tell me what is the correct way to code the following (I want
to call the file

webclient.properties if the locale is English fr_webclient.properties if the
locale is French):

 

What does mean <% here ?

 

<%

      FacesContext fc = FacesContext.getCurrentInstance();

     

      // set locale for JSF framework usage

      fc.getViewRoot().setLocale(Application.getLanguage(fc));

%>

   

 

   <%-- load a bundle of properties with I18N strings --%>

If Application.getLanguage(fc).equals("en")

   <f:loadBundle basename="alfresco.messages.en_webclient" var="msg"/>

Else

   <f:loadBundle basename="alfresco.messages.fr_webclient" var="msg"/>

 

Thanks

Sophie


Re: how to detect in the backing bean (the shale viewcontroller) that the user navigates to another page?

Posted by Costa Basil <co...@yahoo.ca>.
Yes, I think your approach is good. But unfortunatelly, if I do this the table row events (the clicks on commandLink links stored in the table) are not fired because the table is not populated at that time (apply request values) and in the end I have to use other methods to simulate the row clicks. 

I think the issue is that there seems to be no way to tell if is this is a real postback (to the same page) or a postback to navigate somewhere else. Shale reports isPostBack=true in both cases.


Craig McClanahan <cr...@apache.org> wrote: 

On 3/10/06, Costa Basil <co...@yahoo.ca> wrote: Let me give you an example. Let's say I have a table with rows (populated from the database) and I have on each row a commandLink to delete that row. On the same page I have another commandLink to navigate to another page. If I delete the row the table has to be populated as early as possible for the deleteRow event to be fired. However, if I navigate to another page I don't want to query that table from the database which would happen even if I set immediate to true for the commandLink that navigates the other page. Of course I have the option of using a hidden link to delete the row but ...

 That's a pretty common use case, and here's how I would approach it ... populate the table in the prerender() method of the view that contains the table.
 
 This works because, if you actually do navigate to a different page, the prerender() method of *that* page will be called instead of the prerender() method of *this* page.  Thus, you will never waste the time to perform the query (or whatever) to populate the table unless it is actually necessary.
 
 Craig
 

Costa Basil < costa_basil@yahoo.ca> wrote:  I use shale and I was wondering if there is there an easy way to know in a backing bean on the postback that the user actually pressed a commandLink that navigates to another page than the one the backing bean is for. I want to avoid unecessary database calls. 


Thanks   

---------------------------------
Enrich your life at  Yahoo! Canada Finance

   

---------------------------------
Have a question? Yahoo! Canada Answers. Go to Yahoo! Canada Answers     



 

				
---------------------------------
Make free worldwide PC-to-PC calls. Try the new Yahoo! Canada Messenger with Voice

Re: how to detect in the backing bean (the shale viewcontroller) that the user navigates to another page?

Posted by Craig McClanahan <cr...@apache.org>.
On 3/10/06, Costa Basil <co...@yahoo.ca> wrote:
>
> Let me give you an example. Let's say I have a table with rows (populated
> from the database) and I have on each row a commandLink to delete that row.
> On the same page I have another commandLink to navigate to another page. If
> I delete the row the table has to be populated as early as possible for the
> deleteRow event to be fired. However, if I navigate to another page I don't
> want to query that table from the database which would happen even if I set
> immediate to true for the commandLink that navigates the other page. Of
> course I have the option of using a hidden link to delete the row but ...
>

That's a pretty common use case, and here's how I would approach it ...
populate the table in the prerender() method of the view that contains the
table.

This works because, if you actually do navigate to a different page, the
prerender() method of *that* page will be called instead of the prerender()
method of *this* page.  Thus, you will never waste the time to perform the
query (or whatever) to populate the table unless it is actually necessary.

Craig

*Costa Basil <co...@yahoo.ca>* wrote:
>
> I use shale and I was wondering if there is there an easy way to know in a
> backing bean on the postback that the user actually pressed a commandLink
> that navigates to another page than the one the backing bean is for. I want
> to avoid unecessary database calls.
>
>
> Thanks
> ------------------------------
> Enrich your life at *Yahoo! Canada Finance* <http://finance.yahoo.ca>
>
>
> ------------------------------
> Have a question? Yahoo! Canada Answers. Go to *Yahoo! Canada Answers*<http://ca.answers.yahoo.com>
>
>

Re: how to detect in the backing bean (the shale viewcontroller) that the user navigates to another page?

Posted by Costa Basil <co...@yahoo.ca>.
Let me give you an example. Let's say I have a table with rows (populated from the database) and I have on each row a commandLink to delete that row. On the same page I have another commandLink to navigate to another page. If I delete the row the table has to be populated as early as possible for the deleteRow event to be fired. However, if I navigate to another page I don't want to query that table from the database which would happen even if I set immediate to true for the commandLink that navigates the other page. Of course I have the option of using a hidden link to delete the row but ...


Costa Basil <co...@yahoo.ca> wrote: I use shale and I was wondering if there is there an easy way to know in a backing bean on the postback that the user actually pressed a commandLink that navigates to another page than the one the backing bean is for. I want to avoid unecessary database calls. 


Thanks   

---------------------------------
Enrich your life at Yahoo! Canada Finance

		
---------------------------------
Have a question? Yahoo! Canada Answers. Go to Yahoo! Canada Answers