Abd*_*USS 11 jsf el cdi managed-bean
我在将My xhtml页面连接到托管bean时遇到问题,commandButton上的操作有效,但是当传递值时它不起作用.这是我的jsf代码:
<h:form id="form" class="form-signin">
<p:panel id="panel" header=" Authentification" style="" >
<h:panelGrid columns="2" rowClasses="3">
<h:outputLabel for="login" value="Nom d'utilisateur :" styleClass=""/>
<p:inputText id="login" value=" #{authenticationBean.profil.login }" required="true" label="login" >
<f:validateLength minimum="4" />
</p:inputText>
<h:outputLabel for="password" value="Mot de passe :" />
<p:password id="password" value=" #{authenticationBean.profil.password }" required="true" label="password" styleClass=""/>
<p:row>
<p:commandButton id="loginButton" value="Login" ajax="false" action="#{authenticationBean.validate}" />
<h:messages id="messages" globalOnly="false"/>
</p:row>
</h:panelGrid>
</p:panel>
</h:form>
Run Code Online (Sandbox Code Playgroud)
我正在使用morphia将数据映射到mongo db,我还有一个名为profil和一个bean的权限来管理身份验证.这是我的认证bean代码:
public class AuthenticationBean implements Serializable {
private static final long serialVersionUID = 1L;
private Profil profil;
private ProfilDAO profileDao = DAOFactory.getProfilDAO();
public void validate() {
FacesMessage message = new FacesMessage("Succès de l'inscription !");
FacesContext.getCurrentInstance().addMessage(null, message);
}
// getters and setters
Run Code Online (Sandbox Code Playgroud)
这是我的profil权利代码:
@Entity("profils")
public class Profil {
@Id protected ObjectId _id;
protected String nomProfil,prenomProfil,login,password;
@Embedded protected List<Droit> droits;
@Reference protected Admin admin;
public Profil() {
}
//getters and setters ...
Run Code Online (Sandbox Code Playgroud)
这是我提交一些数据并单击提交按钮时得到的错误:
javax.el.PropertyNotWritableException: /index.xhtml @29,125 value=" #{authenticationBean.profil.login }": Illegal Syntax for Set Operation
Run Code Online (Sandbox Code Playgroud)
Bal*_*usC 19
仔细观察该值,并与所有理智的JSF教程/示例试图向您展示:
value=" #{authenticationBean.profil.login }"
Run Code Online (Sandbox Code Playgroud)
空格在属性和EL表达式中很重要.摆脱它:
value="#{authenticationBean.profil.login}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18428 次 |
| 最近记录: |