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中没有看到这一切,这一切都非常有意义 –