jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -


this question has answer here:

i error when trying send values jsf page bean.

i want set values fields in bean, create airplane instance , add database. error telling me use illegal syntax setter part of bean.

why error? didnt find on site helped me problem.

here jsf part:

<h4>add plane</h4>                  <c:if test="#{not empty listairplanebb.error}">                     <div class="alert alert-danger">                         <span class="glyphicon glyphicon-remove"></span> <h:outputtext value="#{listairplanebb.error}" />                     </div>                 </c:if>                 <h:form>                 <table class="table">                     <thead>                         <tr>                             <th>plane make</th>                             <th colspan="1">plane model</th>                             <th colspan="1">plane seats</th>                         </tr>                     </thead>                     <tr>                             <td>                               <h:inputtext value="#{addairplanectrl.setmake(make)}">                                 <f:validatelength minimum="3" />                             </h:inputtext>                         </td>                         <td>                             <h:inputtext id="lastname" value="#{addairplanectrl.setmodel(model)}">                                 <f:validatelength minimum="3" />                             </h:inputtext>                         </td>                         <td>                             <h:inputtext value="#{addairplanectrl.setseats(seats)}">                                 <f:validatelength minimum="1" />                             </h:inputtext>                         </td>                         <td>                             <h:commandbutton value="add plane" class="btn btn-primary" action="#{addairplanectrl.addplane()}" />                         </td>                     </tr>                 </table>                 </h:form> 

here bean:

@named @requestscoped public class addairplanectrl implements serializable{  @inject private flightmodel flightmodel;  private listairplanebb listairplanebb;  private string make;  private string model;  private string seats;  private static final string plane_exist = "plane exists"; private static final string empty_fields = "please fill in fields";  protected addairplanectrl(){     ; }  /* list     error handling */  public string addplane(){      //make sure fields filled, otherwise set error , return redirect false     if(make == null || model == null || seats == null){         listairplanebb.seterror(empty_fields);         return "/private/admin/admincenter?faces-redirect=false";     }      //create planeid     string pid = make.substring(0, 1);     pid += model;      //upload photo in new method [meet requirements, rename photoid planeid, upload folder]      //check if exist     list<airplane> airplanelist = flightmodel.getairplanelist().getbyairplaneid(pid);     if(!airplanelist.isempty()){         listairplanebb.seterror(plane_exist);         return "/private/admin/admincenter?faces-redirect=false";     }      //add plane     airplane airplane = new airplane(make, model, pid, seats);     flightmodel.getairplanelist().create(airplane);     return "/private/admin/admincenter?faces-redirect=true"; }  public string deleteairplane(string planeid){     return ""; }  /**  * @param make make set  */ public void setmake(string make) {     this.make = make; }  /**  * @param model model set  */ public void setmodel(string model) {     this.model = model; }  /**  * @param seats seats set  */ public void setseats(string seats) {     this.seats = seats; } 

}

here error:

javax.faces.component.updatemodelexception: javax.el.propertynotwritableexception: /private/admin/admincenter.xhtml @118,87 value="#{addairplanectrl.setmake(make)}": illegal syntax set operation @ javax.faces.component.uiinput.updatemodel(uiinput.java:866) @ javax.faces.component.uiinput.processupdates(uiinput.java:749) @ javax.faces.component.uiform.processupdates(uiform.java:281) @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1286) @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1286) @ javax.faces.component.uiviewroot.processupdates(uiviewroot.java:1254) @ com.sun.faces.lifecycle.updatemodelvaluesphase.execute(updatemodelvaluesphase.java:78) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.execute(lifecycleimpl.java:198) @ javax.faces.webapp.facesservlet.service(facesservlet.java:646) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:344) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:214) @ edu.cth.dzenkyair.frontend.auth.adminfilter.dofilter(adminfilter.java:40) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:214) @ edu.cth.dzenkyair.frontend.auth.userfilter.dofilter(userfilter.java:39) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:214) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:316) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673) @ com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:415) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:282) @ com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167) @ org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:201) @ org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:175) @ org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235) @ org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:284) @ org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:201) @ org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:133) @ org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:112) @ org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77) @ org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:561) @ org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117) @ org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56) @ org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565) @ org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545) @ java.lang.thread.run(thread.java:745) caused by: javax.el.propertynotwritableexception: /private/admin/admincenter.xhtml @118,87 value="#{addairplanectrl.setmake(make)}": illegal syntax set operation @ com.sun.faces.facelets.el.tagvalueexpression.setvalue(tagvalueexpression.java:136) @ javax.faces.component.uiinput.updatemodel(uiinput.java:832) ... 45 more caused by: javax.el.propertynotwritableexception: illegal syntax set operation @ com.sun.el.parser.astvalue.setvalue(astvalue.java:228) @ com.sun.el.valueexpressionimpl.setvalue(valueexpressionimpl.java:294) @ org.jboss.weld.el.weldvalueexpression.setvalue(weldvalueexpression.java:64) @ com.sun.faces.facelets.el.tagvalueexpression.setvalue(tagvalueexpression.java:131) ... 46 more 

jsf uses managedbeans, managed bean uses bean standards, i.e., to implement serializable, encapsulation , empty constructor

the facelets can communicate managed bean through expression language , use setters editablevalueholder uicomponent.

in case, editablevalueholder using <h:inputtext /> component, when use value="" attribute, correct way call setter use name of property trying set, here's example:

bean:

@named or @managebean @some_scope public class yourbean implements serializable{  private string make;  public void setmake(string make){   this.make = make; }   public string getmake(){   return this.make; }  } 

facelet:

// call setmake(string make)  method <h:inputtext value="#{yourbean.make}" />  // call getmake() method  <h:outputtext value="#{yourbean.make}" /> 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -