0

我有一个带有学生列表的手风琴面板,并且我设置了 dynamic="true",在手风琴面板的选项卡中,我有一个命令按钮,它调用支持 bean 中的方法。这里第一个选项卡的内容是空的,其余的都很好。为了纠正这个问题,我设置了 dynamic="false" 现在选项卡的内容正在出现,但是命令按钮单击不会在第一次单击时调用支持 bean 的方法。我不确定发生了什么.. 我使用的是 prime faces 3.4 和 jsf2

<p:accordionPanel  value="#{testBean.students}" var="stud"  dynamic="true"  activeIndex="#{systemManagedBean.formBean.id}">  

              <p:tab title="#{stud.name}" id="studId">  
             <p:commandButton process="@this"  value="edit" icon="ui-icon-pencil" styleClass="btn-primary" style="margin-left:734px;" action="#{testBean.edit}">

            <f:setPropertyActionListener target="#{testBean.stydent}" value="#{stud}"></f:setPropertyActionListener>

            </p:commandButton> 

我试过 proceess=@form 没有做任何改变..

4

1 回答 1

0

以下代码正在工作:

xhtml:

<h:form>
    <p:accordionPanel value="#{so15320248.students}" var="student">
        <p:tab title="#{student.name}">
            <p:commandButton icon="ui-icon-pencil" value="Edit" actionListener="#{so15320248.edit(student)}"/>
        </p:tab>
    </p:accordionPanel>
</h:form>

托管bean:

@ManagedBean(name = "so15320248")
@ViewScoped
public class SO15320248 implements Serializable {

    private static final long serialVersionUID = -2285963068688871710L;

    private List<Student> students;

    @PostConstruct
    public void init() {
        students = new ArrayList<Student>();
        students.add(new Student("Student 1"));
        students.add(new Student("Student 2"));
    }

    public void edit(Student student) {
        System.out.println("===========================");
        System.out.println(student.getName());
        System.out.println("===========================");
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }
}
于 2013-03-10T09:21:15.400 回答