I tried to parse argument with JSF to managed bean with ajax. my JSF code is this
<h:commandLink id="user" action="#{pageBean.setPage("user")}" >
user
<f:ajax execute="user" render="contentBody" />
</h:commandLink>
managed bean is this
@ManagedBean
public class PageBean {
private String path;
private String page;
public PageBean() {
}
@PostConstruct
public void init(){
path = "/WEB-INF/dashboard.xhtml";
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
}
But when I run this I got following error. Why is that?
Error Parsing /WEB-INF/templete.xhtml: Error Traced[line: 37] Element type "h:commandLink" must be followed by either attribute specifications, ">" or "/>".
You are using double quotes in your attribute around user
.
<h:commandLink id="user" action="#{pageBean.setPage("user")}" >
This results in templete.xml
not beeing a valid XML-File.
Correct example line using single quotes (as proposed by @gWombat):
<h:commandLink id="user" action="#{pageBean.setPage('user')}" >