JSF, EL, Managed Beans - How do I know what getter and setter signatures are?

With JSF, Managed Beans, and EL 2.2 I usually know that a form expression:

#{bean.value}

The corresponding set of functions in the managed bean class is displayed as follows:

@ManagedBean
class Bean {
    private String value;
    public String getValue() { return value; }
    public void setValue( String s ) { value = s; }
}

You can also get and set display properties:

#{bean.value['key']}

Based on something like:

@ManagedBean
class Bean {
    private Map<String, Boolean> kvMap;
    public boolean getValue( String key ) { return kvMap.get( key ); }
    public void setValue( String key, boolean value ) { kvMap.put( key, value ); }
}

So far so good.

I find how I spend more time with JSF, however, that I am trying to write reusable snippets of code. In particular, small xhtml blocks in <ui:composition>blocks that I can include through <ui:include>. What's more, many of the most useful things for me are things like nested sets of checkboxes (our user interface designer just spins over them ;-), and it <ui:repeat>becomes very convenient there.

, <ui:repeat> <ui:include> , , <ui:param> inline - var <ui:repeat>.

UIComponents, , , , JSF (- ).

, , :

- JSF , , ? JSF , getter-only (, ), , , , , , , .

, - , , FacesContext... , , . , , , , , .

, , , .

+5
1

, " Map?".

: . EL put() Map . getter Map. EL get() Map. , MapELResolver.

, :

@ManagedBean
class Bean {
    private Map<String, Boolean> kvMap;
    public Map<String, Boolean> getValue() { return kvMap; }
}

#{bean.value['key']} #{bean.value.key}, . .

<h:selectBooleanCheckbox value="#{bean.value.key}" />

, JBoss Tools Eclipse EL javabeans, . Eclipse bean .

+6

All Articles