While developing a small jsf application with datatable I am having following problem with this error
The method setVar(String) in the type DataTableTag is not applicable for the arguments (JspValueExpression)
in my jsp page i have following code fragment
<h:dataTable id="dt1" value="#{dbdata.empno}" var="item" bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" rows="4" width="50%" dir="LTR" frame="hsides" rules="all" summary="This is a JSF code to create dataTable." >
in my java file i have following 2 code fragments--
while (rst.next())
{
empno.add(i++,new perInfo(rst.getString(1)));
}
public class perI开发者_JAVA百科nfo {
String uname;
public perInfo(String firstName) {
this.uname = uname;
}
public String getUname() {
return uname;
}
}
the data is coming fine from database.
I have found that "var" attribute is giving problem
can you please advise
Looks like you ran into this bug:
Bug 41912 - JSF datatable does not work on tomcat 6.0.9
Regarding the comments on this page a possible workaround would be changing the combination of server and/or jsf version.
Sounds like you're trying to send a String to a relational database when it's expecting another type, like Date or number, to a particular table and column.
HTTP form elements only know about Strings. You should be validating and binding values from the UI on the server side before persisting them in a database.
精彩评论