You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Alexander Papadakis (JIRA)" <de...@myfaces.apache.org> on 2015/04/01 08:46:54 UTC

[jira] [Reopened] (MYFACES-3971) ui:repeat var attribute is not a javax.el.ValueExpression

     [ https://issues.apache.org/jira/browse/MYFACES-3971?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexander Papadakis reopened MYFACES-3971:
------------------------------------------

The following snippet:
{code}

<ui:repeat var="${personRepository.item}" value="#{personRepository.persons}" varStatus="stat">
<h:outputText value="#{var.name} #{stat.index} #{personRepository.item}" /> <br />
</ui:repeat>
{code}

when using the following bean 

{code}
@ManagedBean
@ApplicationScoped
public class PersonRepository implements Serializable {
    private Map<Integer, Person> persons = new TreeMap<Integer, Person>();

    private String item = "var";
    @PostConstruct
    protected void init() {
        persons.put(1, new Person(1, "Person 1", "person1@server.com"));
        persons.put(2, new Person(2, "Person 2", "person2@server.com"));
        persons.put(3, new Person(3, "Person 3", "person3@server.com"));
    }

    public List<Person> getPersons() {
        return new ArrayList<Person>(persons.values());
    }


	public String getItem() {
		return item;
	}
...
}
{code}

Will just print 

{code}
 0
 1
 2 
{code}

while it should print:

{code}
Person 1 0
Person 2 1
Person 3 2
{code}

ui:repeat will correctly iterate over the List BUT will not create the #{var} el variable as it should (because the ui:repeat->var is not evaluated as an expression and it is used literally....

So  the call:
{code}
 getFacesContext().getExternalContext().getRequestMap()
                        .put(var, localModel.getRowData());
{code}

will actually be:

{code}
 getFacesContext().getExternalContext().getRequestMap()
                        .put("${personRepository.item}", localModel.getRowData());
{code}

instead of
{code}
 getFacesContext().getExternalContext().getRequestMap()
                        .put("var", localModel.getRowData());
{code}
.

This is easily reproduced. I am preparing a demo war to showcase the problem 



> ui:repeat var attribute is not a javax.el.ValueExpression
> ---------------------------------------------------------
>
>                 Key: MYFACES-3971
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3971
>             Project: MyFaces Core
>          Issue Type: Bug
>            Reporter: Alexander Papadakis
>
>  As per the spec, the 'var' attribute in ui:repeat should be a javax.el.ValueExpression (must evaluate to java.lang.Object).
> As such, it should be possible to use it in a composite with a value like #{cc.attrs.varname} where varname is a cc:attribute populated where the composite is instantiated.
> ui:repeat as it wotks now, it will now evaluate any el sett in var.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)