方法调用中的JSF转换器:为什么我不需要它们?

时间:2016-02-01 13:54:10

标签: jsf

考虑以下'玩具示例':

我有一个'学生'课程:

public class Student {
    private String name;            
    // getters and setters
}

托管bean,名为“StudentBean”:

@ManagedBean(name = "stdBean")
@ViewScoped
public class StudentBean {
    private List<Student> lstStudents = new ArrayList<>();
    public List<Student> getLstStudents() {
        // populate the lstStudents with some students.        
    }
    public void remove(Student std) {
        lstStudents.remove(std);
    }
}

在正文标记中包含以下内容的XHTML文件:

<h:form>
   <h:dataTable value="#{stdBean.lstStudents}" var="std">
                <h:column>
                    <f:facet name="header">Name</f:facet>
                        #{std.name}
                </h:column>
                <h:column>
                    <h:commandLink action="#{stdBean.remove(std)}" value="Remove"/>
                </h:column>
   </h:dataTable>
</h:form>

注意我正在传递'std'(这是'Student'属于'lstStudent'列表的实例)作为'remove'方法的参数。

问题是:出于哪些原因我不需要学生班的转换器?

祝你好运。圣保罗。

0 个答案:

没有答案