View parameter when navigating to another page

前端 未结 2 1779
独厮守ぢ
独厮守ぢ 2020-12-22 09:49

I am using JSF2, and I need to be able to pass a parameter from one JSF page to another via a commandLink.

I am on page funding.xhtml (ViewScoped) and h

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 10:29

    Use and :

    Source page:

    
        
        
        
    
    

    Destination page (bound):

    
        
    
    
    
    

    Destination page (unbound):

    
        
    
    
    
    

    Backing bean (only if you want to bind the param):

    @ManagedBean
    @ViewScoped
    public class DestinationBacking{
        String fromPage;
    
        public String getFromPage(){
            return fromPage;
        }
    
        public void setFromPage(String frompage){
            fromPage = frompage;
        }
    }
    

    Your view path will be binded to fromPage property from the destination backing bean and after you can use it to return to the original page.

    Also I want to say that this way is a bit 'hackeable' by the end user, I mean, you're passing the original path through pure url. See also other ways to achieve that, as flash scope, which is very useful specially if you're working with @ViewScoped beans.

提交回复
热议问题