0

I checked all the ways its not the Case sensitive problem.But I have same naming convention in both bean and jsf page but still I am getting an error property not found.

I am using primefaces-5.2 and I have that jar in WEB-INF/lib.

Below is the code:

Bean Class

public class User implements Serializable{
    public String getSomeMethod(){
        System.out.println("Hi from SomeMethod");
        return "";
     }
 }

my index.XHTMl page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" >

    <h:head>
        <!-- Mimic Internet Explorer 8 -->
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"  />
        <title>User Details</title>
        <script type="text/javascript">
            window.location.hash="no-back-button";
            window.location.hash="Again-No-back-button";
            //again because google chrome don't insert first hash into history
            window.onhashchange=function(){
                window.location.hash="no-back-button";
            }
          </script> 
    </h:head>

    <h:body>
        <h:outputStylesheet library="css" name="application.css" />
        <img height="80" width="100%" src="#{facesContext.externalContext.requestContextPath}/images/LSHeader.jpg" alt="logo" />
        <form name="myform" action="#{user.getSomeMethod}" method="post"></form>
    </h:body>
</html>     

Faces-config

<?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">

    <managed-bean>
        <managed-bean-name>user</managed-bean-name>
        <managed-bean-class>com.tn.gov.User</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
 </faces-config>

Error what i am receiving.

javax.el.ELException: /index.xhtml: Property 'getSomeMethod' not found on type com.tn.gov.User

Jiri Tousek
  • 12,211
  • 5
  • 29
  • 43
tom
  • 5,114
  • 6
  • 24
  • 36
  • Is `User` a managed bean? – Luiggi Mendoza Nov 25 '15 at 17:09
  • Yes, It is managed bean – tom Nov 25 '15 at 17:13
  • 1
    Ok, but `User#getXyz` is not interpreted as a method. It should be `User#xyz`. JSF relies in Java naming convention standard and getter/setter methods are for properties of the class, and only for that. Also, You cannot apply JSF freely in any non-JSF component. Also, in this case the generated HTML will be like this: `
    ` which is wrong HTML. Before trying JSF on your own, I recommend you to check tutorials on basic HTML and then read/follow tutorials on JSF.
    – Luiggi Mendoza Nov 25 '15 at 17:16
  • Initially i tried it user.somemethod it dint worked and googled on this someone suggested to use getSomemethod instead, And that dosnt work either. – tom Nov 25 '15 at 17:18
  • Because binding with # symbol is deferred, as explained here: [Expression Language](http://stackoverflow.com/tags/el/info). I guess after you read that you will have a better understanding of how EL works and what are you trying to do here (and the odd results you will get if you make this work). – Luiggi Mendoza Nov 25 '15 at 17:20
  • 1
    html form tag attribute action should not be used like this with a MB. please replace
    with
    – Mahendran Ayyarsamy Kandiar Nov 25 '15 at 17:26
  • 1
    @MahendranAyyarsamyKandiar and why is that for? What's the purpose? Why would that *work* and OP's attempt not? Why you give the fish to a fisherman rather than explaining him/her how to get the fish instead? – Luiggi Mendoza Nov 25 '15 at 17:28
  • @LuiggiMendoza I did not find a good link to explain. i found this http://stackoverflow.com/questions/5715308/how-to-define-form-action-in-jsf but i was afraid OP would be confused even more. – Mahendran Ayyarsamy Kandiar Nov 25 '15 at 17:40
  • 1
    @MrListener: No realy. Normally jsf tags decide if an EL is to be interpreted as a method expression (calling a method) or a value expression (calling a getter/setter of a property), the latter being the default. In this case, the `form` tag is not interpreted as a jsf tag but as plain html. And the default way of accessing it is applied (assuming the getSomeMethod being the name of the property) and trying it to call via getGetSomeMethod which ofcourse does not work. – Kukeltje Nov 25 '15 at 18:43

0 Answers0