0
我正在創建一個portlet,其中在視圖和編輯模式下適用。我想要一種情況,並且更新將portlet從編輯模式切換到視圖模式。下面是我的代碼片斷Viewscoped託管的Bean和Portlets
@ManagedBean(name = "portletBackingBean")
@ViewScoped
public class FirstPortlet extends GenericFacesPortlet implements Serializable {
private transient Logger logger = LoggerFactory.getLogger(getClass());
private void doActionResponse(PortletMode mode){
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext =
facesContext.getExternalContext();
ActionResponse actionresponce = (ActionResponse) externalContext.getResponse();
try {
actionresponce.setPortletMode(mode);
} catch (PortletModeException e) {
// TODO Auto-generated catch block
LiferayFacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Error setting property"));
}
}
private String userName;
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
//submitting the values
public void doSubmit(){
if(this.userName != null) {
logger.debug("value of property in backing bean set to " + getUserName());
doActionResponse(PortletMode.VIEW);
}
}
到目前爲止,一切都很好,但隨後在該portlet視圖模式呈現的#{portletBackingBean.userName}
值爲null。
請有沒有提前做這個
感謝
非常感謝,在2011年的Liferay中沒有看到這一切,這一切都非常有意義 –