2013-03-10 44 views
0

我有一個手風琴面板與學生的列表,我已設置動態=「true」,在手風琴面板的選項卡中,我有命令按鈕,調用方法在後臺bean中。 這裏第一個標籤的內容是空的,休息一切都很好。爲了糾正這個問題,我現在設置了dynamic =「false」,現在tab的內容出現了,但是命令按鈕的點擊並沒有在第一次點擊時調用backing bean的方法。蔭不知道發生了什麼事..用黃金進出口面臨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 = @的形式並沒有做任何改變..

回答

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; 
    } 
} 
相關問題