java - javax.el.PropertyNotWritableException: /index.xhtml @29,118 value="": Illegal Syntax for Set Operation -


i want create login screen localization option translate name , when change default english arabic crash

here faces.config.xml

<?xml version="1.0" encoding="utf-8"?> <faces-config     xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/javaee      http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"     version="2.0">      <application>            <locale-config>                 <default-locale>en</default-locale>                 <supported-locale>ar</supported-locale>            </locale-config>        <resource-bundle>         <base-name>mypack.enar</base-name>         <var>msg</var>        </resource-bundle>      </application> </faces-config> 

managedbean

import java.io.serializable; import java.util.linkedhashmap; import java.util.locale; import java.util.map; import javax.faces.bean.managedbean; import javax.faces.bean.requestscoped; import javax.faces.context.facescontext; import javax.faces.event.valuechangeevent;  /**  *  * @author body  */ @managedbean(name = "localize") @requestscoped public class localizembean implements serializable {      /**      * @return countries      */     public static map<string, object> getcountries() {         return countries;     }      /**      * @param acountries countries set      */     public static void setcountries(map<string, object> acountries) {         countries = acountries;     }      private string localecode;      /**      * creates new instance of localizembean      */     public void setlocalecode(string localecode) {         this.localecode = localecode;     }      public map<string, object> getcountriesinmap() {         return getcountries();     }      public string getlocalecode() {         return localecode;     }     private static map<string, object> countries;      static {         setcountries(new linkedhashmap<string, object>());         getcountries().put("english", locale.english); //label, value         getcountries().put("arabic", locale.unicode_locale_extension);     }      public void countrylocalecodechanged(valuechangeevent e) {          string newlocalevalue = e.getnewvalue().tostring();          //loop country map compare locale code         (map.entry<string, object> entry : getcountries().entryset()) {              if (entry.getvalue().tostring().equals(newlocalevalue)) {                  facescontext.getcurrentinstance()                         .getviewroot().setlocale((locale) entry.getvalue());              }         }     } } 

jsf page

<h:head>         <title>my login page</title>         <h:outputstylesheet library="mycss" name="login-box.css"/>     </h:head>     <h:body>         <h:form>             <div style="padding: 100px 0 0 250px;">                   <div id="login-box">                      <h2>login</h2>                     login screen                     <br />                     <h:selectonemenu value="#{localize.localecode}" onchange="submit();"                                      valuechangelistener="#{localize.countrylocalecodechanged}">                         <f:selectitems value="#{localize.countriesinmap}" />                      </h:selectonemenu>                     <br />                     <div id="login-box-name" style="margin-top:20px;">                         <h:outputlabel value="#{msg.namee}" />                     </div>                     <div id="login-box-field" style="margin-top:20px;">                         <h:inputtext  styleclass="form-login" title="username" value="" size="30" maxlength="2048" />                     </div>                     <div id="login-box-name">password:</div><div id="login-box-field"><h:inputsecret styleclass="form-login" title="password" value="" size="30" maxlength="2048" /></div>                     <br />                     <div class="login-box-options"><h:selectbooleancheckbox value="1"/>remember me<h:commandlink style="margin-left:30px;" value="forget password"/></div>                     <br />                     <br />                     <h:commandbutton styleclass="button"/>                 </div>             </div>         </h:form>     </h:body> </html> 

the exception when change in combobox

javax.faces.component.updatemodelexception: javax.el.propertynotwritableexception: /index.xhtml @29,118 value="": illegal syntax set operation     @ javax.faces.component.uiinput.updatemodel(uiinput.java:853)     @ javax.faces.component.uiinput.processupdates(uiinput.java:735)     @ javax.faces.component.uiform.processupdates(uiform.java:281)     @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1242)     @ javax.faces.component.uicomponentbase.processupdates(uicomponentbase.java:1242)     @ javax.faces.component.uiviewroot.processupdates(uiviewroot.java:1231)     @ 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:118)     @ javax.faces.webapp.facesservlet.service(facesservlet.java:593)     @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1550)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:343)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217)     @ org.netbeans.modules.web.monitor.server.monitorfilter.dofilter(monitorfilter.java:393)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:279)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:175)     @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:655)     @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:595)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:161)     @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:331)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:231)     @ com.sun.enterprise.v3.services.impl.containermapper$adaptercallable.call(containermapper.java:317)     @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:195)     @ com.sun.grizzly.http.processortask.invokeadapter(processortask.java:860)     @ com.sun.grizzly.http.processortask.doprocess(processortask.java:757)     @ com.sun.grizzly.http.processortask.process(processortask.java:1056)     @ com.sun.grizzly.http.defaultprotocolfilter.execute(defaultprotocolfilter.java:229)     @ com.sun.grizzly.defaultprotocolchain.executeprotocolfilter(defaultprotocolchain.java:137)     @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:104)     @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:90)     @ com.sun.grizzly.http.httpprotocolchain.execute(httpprotocolchain.java:79)     @ com.sun.grizzly.protocolchaincontexttask.docall(protocolchaincontexttask.java:54)     @ com.sun.grizzly.selectionkeycontexttask.call(selectionkeycontexttask.java:59)     @ com.sun.grizzly.contexttask.run(contexttask.java:71)     @ com.sun.grizzly.util.abstractthreadpool$worker.dowork(abstractthreadpool.java:532)     @ com.sun.grizzly.util.abstractthreadpool$worker.run(abstractthreadpool.java:513)     @ java.lang.thread.run(thread.java:722) caused by: javax.el.propertynotwritableexception: /index.xhtml @29,118 value="": illegal syntax set operation     @ com.sun.faces.facelets.el.tagvalueexpression.setvalue(tagvalueexpression.java:136)     @ javax.faces.component.uiinput.updatemodel(uiinput.java:818)     ... 38 more 

please read exception message. answer straight in there.

javax.el.propertynotwritableexception: /index.xhtml @29,118 value="": illegal syntax set operation

at line 29, character 118 of /index.xhtml you've value="". not valid syntax el value expression should writable through setter method.

normally, specify value attribute value="#{bean.property}" wherein bean has getproperty() , setproperty() method conform javabeans specification.

it's one:

<h:inputtext  styleclass="form-login" title="username" value="" size="30" maxlength="2048" /> 

i'm not sure why specified value that. plain wrong. should either remove altogether

<h:inputtext  styleclass="form-login" title="username" size="30" maxlength="2048" /> 

or bind valid bean property

<h:inputtext  styleclass="form-login" title="username" value="#{somebean.username}" size="30" maxlength="2048" /> 

please note problem has nothing changing jsf locale.


unrelated concrete problem, nesting forms illegal in html , therefore in jsf. should split language selection , user login on 2 separate forms. don't want submit login data when change language. further, may find hints in answer helpful how change jsf locale: localization in jsf, how remember selected locale per session instead of per request/view


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -