【问题标题】:Illegal Syntax for Set Operation集合操作的非法语法
【发布时间】:2013-08-20 13:41:12
【问题描述】:

我在将我的 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>

我正在使用 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 

这是我的个人资料实体代码:

@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 ...

这是我在提交一些数据并单击提交按钮时遇到的错误:

javax.el.PropertyNotWritableException: /index.xhtml @29,125 value=" #{authenticationBean.profil.login }": Illegal Syntax for Set Operation

【问题讨论】:

  • 看起来你缺少一个二传手。请将您的设置器代码添加到问题中。

标签: jsf cdi el managed-bean


【解决方案1】:

仔细查看价值并与所有理智的 JSF 教程/示例尝试向您展示的内容进行比较:

value=" #{authenticationBean.profil.login }"

空格在属性和 EL 表达式中很重要。摆脱它:

value="#{authenticationBean.profil.login}"

【讨论】:

  • 谢谢。我遇到了类似的问题,Primefaces 在大括号后有一个空格并得到相同的错误&lt;p:column ... filterValue="#{myView.filterConfig.category} "/&gt;
  • 很难看!这可能是一个瓶颈
猜你喜欢
  • 2013-01-10
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
  • 2017-07-02
  • 2012-03-18
  • 2017-02-21
  • 2014-08-13
相关资源
最近更新 更多