[ 
https://issues.apache.org/jira/browse/MYFACES-3971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14390089#comment-14390089
 ] 

Alexander Papadakis edited comment on MYFACES-3971 at 4/1/15 6:47 AM:
----------------------------------------------------------------------

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", "[email protected]"));
        persons.put(2, new Person(2, "Person 2", "[email protected]"));
        persons.put(3, new Person(3, "Person 3", "[email protected]"));
    }

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


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

Will just print 

{code}
 0 var
 1 var
 2  var
{code}

while it should print:

{code}
Person 1 0 var
Person 2 1 var
Person 3 2 var
{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 




was (Author: alpapad):
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", "[email protected]"));
        persons.put(2, new Person(2, "Person 2", "[email protected]"));
        persons.put(3, new Person(3, "Person 3", "[email protected]"));
    }

    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)

Reply via email to