【发布时间】:2013-08-23 16:15:35
【问题描述】:
我知道有很多类似的主题,但不像我的:
我有一个 requestscope bean:
@ManagedBean
@RequestScoped
public class Bean implements Serializable{
private String username = ""; //managed by textbox
private String password = ""; //managed by textbox
private String id ="-";
//Load the Parameter as usual:
@PostConstruct
public void fetchParams(){
System.out.println("FETCH PARAMS");
FacesContext facesContext = FacesContext.getCurrentInstance();
String id = facesContext.getExternalContext().getRequestParameterMap().get("id");
if(id == null || id.length() == 0) return;
setId(id);
}
// getters & setters
public void doSomething(){ //executed when clicked on the sumbit-button on the jsf-site
StaticFunctions.doSomething(this);
}
}
代码执行以下操作: 它检索get-parameter“id”并将其保存到String id(由string.out....确认)。
但是当 doSomething() 方法被执行并且之前存储的“id”被读取并返回“-”时(就像什么都没发生一样)。
为什么会这样?
【问题讨论】:
标签: jsf parameters parameter-passing managed-bean