0

I have a jsf page and java class:

 <p:panelGrid id="grid" columns="2">      
     <h:outputText value="ID:"/>
     <h:outputText value="#{TesztBean.select.id}"/>
     <h:outputText value="Name:"/>
     <h:outputText value="#{TesztBean.select.name}"/>
     <h:outputText value="Age:"/>
     <h:outputText value="#{TesztBean.select.age}"/>
     <h:outputText value="Kapcsolatfelvetel megtortent:"/>                    
     <h:inputText  value="#{TesztBean.select.kapcsolatfelvetel_megtortent}" size="10" rendered="#{TesztBean.canEdit}" />
     <h:outputText value="#{TesztBean.select.kapcsolatfelvetel_megtortent}" rendered="#{not TesztBean.canEdit}" />
     <h:outputText value="Levélküldés dátuma:"/>
     <h:inputText  value="#{TesztBean.select.levelkuldesenek_datuma}" size="10" rendered="#{TesztBean.canEdit}" />
     <h:outputText value="#{TesztBean.select.levelkuldesenek_datuma}" rendered="#{not TesztBean.canEdit}" />
     <h:outputText value="Képzés kezdete:"/>        
     <h:inputText  value="#{TesztBean.select.kepzes_kezdete}" size="10" rendered="#{TesztBean.canEdit}" />
     <h:outputText value="#{TesztBean.select.kepzes_kezdete}" rendered="#{not TesztBean.canEdit}" />
     <h:outputText value="Képzés vege:"/>                    
     <h:inputText  value="#{TesztBean.select.kepzes_vege}" size="10" rendered="#{TesztBean.canEdit}" />
     <h:outputText value="#{TesztBean.select.kepzes_vege}" rendered="#{not TesztBean.canEdit}" />
     <h:commandButton id="commandBena"  value="Edit" actionListener="#{TesztBean.editTeszt}" rendered="#{not TesztBean.canEdit}" />                                                                     
</p:panelGrid>

Class:

private boolean canEdit = false;;

public boolean isCanEdit() {
    return canEdit;
}

public void setCanEdit(boolean canEdit) {
    this.canEdit = canEdit;
}   

public String getEditTeszt(){
    setCanEdit(true);
    return null;
}   

enter image description here

I would like to editing intputtext/outputtext values. when i clicked the edit button, then i see that in the server log:

[#|2014-05-19T18:08:42.607+0200|SEVERE|oracle-glassfish3.1.2|javax.faces.event|_ThreadID=74;_ThreadName=Thread-2;|javax.el.MethodNotFoundException: Method not found: hu.educatio.osszesito.teszt.TesztBean@37247706.editTeszt() at com.sun.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:160)

javax.enterprise.resource.webcontainer.jsf.context|_ThreadID=74;_ThreadName=Thread-2;|Method not found: hu.educatio.osszesito.teszt.TesztBean@37247706.editTeszt() javax.faces.event.AbortProcessingException: Method not found: hu.educatio.osszesito.teszt.TesztBean@37247706.editTeszt() at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:182)

how can i edit outputtext values?

Joffrey Hernandez
  • 1,809
  • 3
  • 21
  • 39
fuge007
  • 39
  • 2
  • 10

1 Answers1

1

Your method is named getEditTeszt(), which makes it eligible to be a bean property by convention (with the get prefix and a return value). So when you use "#{TesztBean.editTeszt}" for you actionListener, it's reading it as a property and not a method, as you are leaving out the get in the getEditTeszt. Hence the exception message "Method not found", as a method is required.

A simple fix would be just to put in the get"#{TesztBean.getEditTeszt}". But in this context, it makes no sense. First of all, your action listener method has no reason to return anything. Especially when all you're doing is returning null. You should rather make the method return void. You may be mistaking/missing the difference between actionListener and action, the latter being the one where you do want to return a string, for navigational purposes. Read more at Differences between action and actionListener

I would change the name of the method to something else more semantically appropriate. You should avoid using get for your method prefix, unless they are actual getters. You've just met one of the reason why.

Community
  • 1
  • 1
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • I modified the actionlistener: `` and i add a method: `public void setEditTeszt(ActionEvent event){ setCanEdit(true); }` . When i click button, i see in the server log : `canedit is true` but i can not editing inputText/outputText values, Why? Thank you – fuge007 May 20 '14 at 08:44