未调用commandLink操作

时间:2017-05-30 02:22:13

标签: jsf jsf-2

我正在使用带有glassfish的netbeans

在我的.xhtml文件中,有一个链接,我希望将其称为操作shopBean.instructorScheduleById()

<p:commandLink styleClass="tooltip tour-sched" 
    rendered="#{shopBean.instructorSchedule!=null}"
    update=":dialogFormTS" action="#
    {shopBean.instructorScheduleById()}"                                             
    oncomplete="dlgTS.show()" process="@this"                                              
    ajax="true">TS<h:outputText styleClass="tooltiptext" 
    value="#{shopBean.instructorSchedule.name}"/>
</p:commandLink>

Bean文件

@ManagedBean(name = "shopBean")
@SessionScoped
public class ShopBean {

    public ShopBean() {}

    public void getInstructorScheduleById(){
        System.out.println("hello");

    }


}

我查看了网络下的开发人员工具,我看到有一个ajax请求但是当我查看glassfish输出时,没有单词hello

1 个答案:

答案 0 :(得分:2)

根据我在stackoverflow上学到的内容,get前缀用于getter方法,这意味着它必须具有返回值。

public void sum(){
    int num1 = 1;
    int num2 = 2;
    System.out.println(num1 + num2);
}
// xhtml
<p:commandButton action="#{bean.sum()}" />

如果你想从getter方法中获取值:

pivate int sum;
public int getSum(){
    return this.sum;
}
public void setSum(sum){
    this.sum = sum;
}
// xhtml
<p:outputText value="#{bean.sum}" />

问题的快速解决方案是删除您的get前缀 豆。

相关问题