java—传递jsf参数而不是实现setter方法

kt06eoxx  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(296)

我有一个带有commandlink的datatable,我想把一个对象传递给bean。commandlink上的action属性直接指向同一页,即没有导航。结果(我认为/怀疑),或者出于其他原因,bean中的setter方法没有实现,因此我在bean中的对象为null。我怎样才能解决这个问题。下面是datatable、setter和我的方法的摘录。thnx公司

<h:commandLink value="Delete"actionListener="#bOQMasterManager.removeBOQ}" action="boqmaster">
     <f:setPropertyActionListener target="#{bOQMasterManager.boqmasterPK}" 
        value="#{boqs.boqmasterPK}" />
   </h:commandLink>

public void setBoqmasterPK(BoqmasterPK boqmasterPK) {
     System.out.println("In the setter!!!");
    this.boqmasterPK = boqmasterPK;

}

public void removeBOQ(ActionEvent event) {
    try {
        System.out.println("In removeBOQ!!!");

        request.removeBoq(boqmasterPK);
        logger.info("Removed BOQ .");
    } catch (IllegalArgumentException e) {
        System.out.println("In the exception!!!"+e.getMessage());

    }
}
u91tlkcl

u91tlkcl1#

首先我希望

actionListener="#bOQMasterManager.removeBOQ}"

actionListener="#{bOQMasterManager.removeBOQ}"

以及 setBoqmasterPK 定义于 bOQMasterManager 豆和 getBoqmasterPK 必须在中定义 boqs 不管是什么。

public void setBoqmasterPK(BoqmasterPK boqmasterPK) {
    System.out.println("In the setter!!!");
    this.boqmasterPK = boqmasterPK;
}

相关问题