user155542
user155542

Reputation: 501

Wrong setter called by jsf

my problem is:

the first setter not second setter is call, not undestand? lets go

my managed bean:

public class ManagedBean {

    public Pessoa getPersonByParam(String a){
        return hash.get(a);
    }

}

my page:

<h:inputText value="#{mbean.getPersonByParam(param).name}">
</h:inputText>

my model:

public class Person {

    private Long id; 
    private String name;

    // getter / setter

}

my stack:

Servlet.service() for servlet Faces Servlet threw exception: javax.el.PropertyNotFoundException:/time.xhtml @37,82 value="#
{mbean.getPersonByParam(param).name}": /time.xhtml @35,74 value="#
{mbean.getPersonByParam(param).name}": The class 'br.com.diario.test.ManagedBean' does not have the property 'getPersonByParam'.

any idea?

Upvotes: 0

Views: 70

Answers (1)

amedeo avogadro
amedeo avogadro

Reputation: 595

From an EL expression you can access Array, HashMap and TreeMap. So it is better if you declare your HashMap as a property, this way you can access it in the XHTML page. Example

JAVA CODE

public class ManagedBean {

    HashMap<String, Person> hash = new HashMap<String, Person>();

    public HashMap<String, Person> getHash(){
        return hash;
    }
}

XHTML CODE

<h:inputText value="#{mbean.hash[param].name}" />

Upvotes: 1

Related Questions