0

i'm new with jsf technology and use of managed bean.

I'm reading the Java Platform, Enterprise Edition The Java EE Tutorial release 7 but it seems to be not clear, i have different problem how in example below :

<h:selectOneMenu value="#{user.age}" onchange="submit()" valueChangeListener="#{user.ageChanged}">
    <f:selectItems value="#{user.ages}" />
    <f:converter converterId="javax.faces.Integer"/>
</h:selectOneMenu>


<h:inputText id="name" value="#{user.name}" required="true" validator="#{user.validateName}" valueChangeListener="#{user.nameChanged}" onchange ="submit()" />

the first one do the job, but the second not it displays:

'managedBean.User' does not have the property nameChanged.

but ageChanged is not a property but the first example do the job

but i'm using method expression to refers method nameChanged that it's present on the bean user,

i'm confusing, too with use or not of the bracket on methods expression:

valueChangeListener="#{user.nameChanged}" or valueChangeListener="#{user.nameChanged()}" what is the properly way to use methods expression? i say this cause in another example having method with no parameters, the two approaches had different behave, first the same error about property missing, the second Apparently worked.

any help? a speak about method expressions it's appreciated to. thank you.

jklee
  • 2,198
  • 2
  • 15
  • 25
  • Your second example looks like a syntax issue. You're closing your inputText open tag prior to declaring the valueChangeListener attribute. Unless this is a copy+paste error in the question, fixing that should resolve your issue. Otherwise at least include your Java method signatures. In regards to method expressions, if you're following java beans naming conventions the two should be synonymous. – axemoi May 05 '17 at 03:06
  • yes, it was that, i fixed it. I appreciate your help thank you. – JavaFxGameProgrammer May 06 '17 at 07:43
  • Not a problem. Also see if this gives you more details regarding the method expressions: http://stackoverflow.com/a/3909382/2780051 – axemoi May 07 '17 at 00:09

0 Answers0