2017-03-21 1 views
0

로 사용자 입력에 연결합니다.Prettyfaces 내가 내 XHTML 코드를 다음있어 매개 변수

이 메서드에서 전달 된 매개 변수를 읽고 싶습니다. 매개 변수가 JSF의 요청 매개 변수 맵이나 쿼리 문자열의 일부가 아닙니다 (com.ocpsoft.pretty.PrettyContext.getCurrentInstance().getRequestQueryString())

어떻게 매개 변수를 backing 빈에 바인딩하지 않고 init 메소드에 전달할 수 있습니까?

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

import de.financeme.view.menu.NaviCase; 

import javax.annotation.ManagedBean; 
import javax.faces.bean.ViewScoped; 

import lombok.Getter; 
import lombok.Setter; 

@ManagedBean 
@ViewScoped 
@URLMapping(id = "addEntity", pattern = "/entity/add", viewId = "/entity/add.xhtml") 
public class Bean { 

    @Getter 
    @Setter 
    private String month; 

    @Getter 
    @Setter 
    private int year; 

    @URLAction(onPostback = false) 
    public void init() { 
    // month = null 
    // year = 0 
    } 
} 

백킹 빈에 바인딩하는 경우에도 마찬가지입니다. 제출 기능을 호출하지 않습니다. 그래서 그들은 그들 각각의 분야에 저장되지 않을 것입니다.

무엇이 잘못 되었나요? 내가 여기서 무엇을 놓치고 있니?

+0

이 당신의 빈과 매핑 코드를 기입하십시오. – chkal

+0

힌트를 보내 주셔서 감사합니다! 그게 충분한 정보입니까? – alexander

답변

0

패턴에서 빈에 매개 변수를 바인딩해야합니다. 이런 식으로 뭔가 :

<pretty:link value="Create" mappingId="pretty:addEntity"> 
    <f:param name="year" value="2017" /> 
    <f:param name="month" value="12" /> 
    Create Entity 
</pretty:link> 

그리고 콩 :이 같은

@ManagedBean 
@ViewScoped 
@URLMapping(id = "addEntity", 
    pattern = "/entity/#{bean.year}/#{bean.month}/add", 
    viewId = "/entity/add.xhtml") 
public class Bean { 

    // ... 

} 

지금 당신은 얻을 것이다 링크 :

/entity/2017/12/add

+0

사용자 입력을 어떻게 처리합니까? 기본적으로 나는 사용자가 월과 연도를 채우길 원한다. 그러면 사용자는'pretty : link'를 클릭하여'addEntity' 페이지로 리디렉션된다. – alexander

관련 문제