2014-10-14 1 views
0

Managed Bean에 여러 개의 PrettyFaces 주석이 있습니다. 전달 된 매개 변수를 보지 않고 페이지가로드 된 진입 점을 어떻게 결정합니까?Pretty Faces 다중 주석이로드 되었습니까?

import com.ocpsoft.pretty.faces.annotation.URLAction; 
import com.ocpsoft.pretty.faces.annotation.URLMapping; 
import com.ocpsoft.pretty.faces.annotation.URLMappings; 

@ManagedBean(name = "bean") 
    @ViewScoped 
    @URLMappings(mappings = { 
      @URLMapping(id = "addObject", pattern = "add/type-#{bean.type}", viewId = "/views/object.jsf"), 
      @URLMapping(id = "editObject", pattern = "edit/#{bean.objId}", viewId = "/views/object.jsf") 
    }) 
    public class Bean implements Serializable { 
     private Long type; 
     private Long objId; 

     @URLAction(onPostback = false) 
     public void load() { 
       if(objId!=null){ 
        //edit mode 
       }else{ 
        // add mode 
       } 
     }  
     // getters/setters 
    } 

답변

1

는이 같은 PrettyContext usind 현재 매핑의 ID에 액세스 할 수 있습니다

String id = PrettyContext.getCurrentInstance().getCurrentMapping().getId(); 
+0

기독교가 올바른지. – Lincoln