But after adding second element I get error:list size = 1
Why does it happens?Error Rendering View[/tab.xhtml]: javax.el.PropertyNotFoundException: /tab.xhtml @65,50 value="#{stackElement.name}": The class 'java.lang.String' does not have the property 'name'. ...
Caused by: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'name'.
ERROR [io.undertow.request] (default task-4) UT005023: Exception handling request to /Play/tab.xhtml: java.lang.IllegalStateException: CDATA tags may not nest ...
Page
Code: Select all
<h:form>
<p:commandButton update="stack" value="Use in expression" action="#{bean.tab}">
<f:param name="i" value="13" />
</p:commandButton>
<p:orderList id="stack" value="#{expression.list}" var="stackElement"
itemLabel="#{stackElement}" itemValue="#{stackElement}" controlsLocation="none" >
<!-- <p:ajax event="reorder" listener="#{expression.onReorder}" /> -->
<p:column>
<h:outputText value="#{stackElement.name}" />
</p:column>
</p:orderList>
</h:form>
Code: Select all
@ManagedBean @RequestScoped
public class Bean implements Serializable {
@ManagedProperty(value="#{expression}")
private Expression ex;
public void tab() {
ex.addStackElement( new StackElement((int) System.currentTimeMillis(), "tab") );
}
// getters-setters
Code: Select all
@ManagedBean @SessionScoped
public class Expression implements Serializable {
private List<StackElement> list = new ArrayList<StackElement>();
public void addStackElement(StackElement stackElement) {
list.add(stackElement);
System.out.println("list size = " + list.size());
}
// getters-setters
Code: Select all
public class StackElement {
private int id;
private String name;
public StackElement(int id, String name) {
this.id = id;
this.name = name;
}
// getters-setters