f:setPropertyActionListener 和 h:dataTable 的问题
我试图使用 setPropertyActionListener< 将两个参数(
nomComposantARejouer
、typeFileARejouer
)传递给操作方法(gestionnaireMessagesController.rejouerMessage
) /code> (我们使用 jsf 1.2)。
这是相关的jsp代码:
<h:column>
<h:columnHeaderFacet>
<h:columnHeader value="#{msgs['pilotage.coordinateur.libelle.rejouer']}" />
</h:columnHeaderFacet>
<h:commandLink id="rejouer"
value="#{msgs['pilotage.coordinateur.libelle.rejouer']}"
action="#{gestionnaireMessagesController.rejouerMessage}">
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.nomComposantARejouer}"
value="#{gestionnaireMessagesController.nomComposant}" />
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.typeFileARejouer}"
value="#{gestionnaireMessagesController.typeFile}" />
</h:commandLink>
</h:column>
但是,我总是得到一个NPE,因为在操作方法中使用时两个参数都为空:
public String rejouerMessage() {
log.debug("-->"+nomComposantARejouer);//null
ParamResultatMessagesDTO message= (ParamResultatMessagesDTO) messagesTableau.getRowData();
log.debug("MessageId: " + message.getMessageId());
try {
Pager p = Pager.getInstance();
ParamRejouerMessageDTO prm = new ParamRejouerMessageDTO();
prm.setMessageId(message.getMessageId());
prm.setFileGet(nomsFilesMap.get(nomComposantARejouer).get(typeFileARejouer));
prm.setFilePut(nomsFilesMap.get(nomComposantARejouer).get("TASKQ"));
RejouerMessageService serv = (RejouerMessageService) this.getService(ServiceCst.REJOUER_MESSAGE_SERVICE);
serv.rejouerMessage(prm);
} catch (BusinessException e) {
this.addMessage(e);
} catch (ServiceException e) {
this.addMessage(e);
}
return chargerPage(); // TODO Navigation case.
}
我不确定我出了什么问题。有人可以帮忙吗?
仅供参考,变量 nomComposant
和 typeFile
可以毫无问题地显示,并且不为 null。
还要忽略 h:columnHeaderFacet 标签。它们是我重命名的内部标签。
I am trying to pass two parameters i.e. (nomComposantARejouer
, typeFileARejouer
) to an action method (gestionnaireMessagesController.rejouerMessage
) using the setPropertyActionListener
(we use jsf 1.2).
Here is the relevant jsp code:
<h:column>
<h:columnHeaderFacet>
<h:columnHeader value="#{msgs['pilotage.coordinateur.libelle.rejouer']}" />
</h:columnHeaderFacet>
<h:commandLink id="rejouer"
value="#{msgs['pilotage.coordinateur.libelle.rejouer']}"
action="#{gestionnaireMessagesController.rejouerMessage}">
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.nomComposantARejouer}"
value="#{gestionnaireMessagesController.nomComposant}" />
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.typeFileARejouer}"
value="#{gestionnaireMessagesController.typeFile}" />
</h:commandLink>
</h:column>
However, I always get a NPE because both parameters are null when used in the action method:
public String rejouerMessage() {
log.debug("-->"+nomComposantARejouer);//null
ParamResultatMessagesDTO message= (ParamResultatMessagesDTO) messagesTableau.getRowData();
log.debug("MessageId: " + message.getMessageId());
try {
Pager p = Pager.getInstance();
ParamRejouerMessageDTO prm = new ParamRejouerMessageDTO();
prm.setMessageId(message.getMessageId());
prm.setFileGet(nomsFilesMap.get(nomComposantARejouer).get(typeFileARejouer));
prm.setFilePut(nomsFilesMap.get(nomComposantARejouer).get("TASKQ"));
RejouerMessageService serv = (RejouerMessageService) this.getService(ServiceCst.REJOUER_MESSAGE_SERVICE);
serv.rejouerMessage(prm);
} catch (BusinessException e) {
this.addMessage(e);
} catch (ServiceException e) {
this.addMessage(e);
}
return chargerPage(); // TODO Navigation case.
}
I am not sure what I am getting wrong. Can anyone please help?
FYI, the variables nomComposant
and typeFile
can be displayed without problem and are not null.
Also ignore the h:columnHeaderFacet tags. They are inhouse tags that I've renamed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您基本上正在做:
在表单提交的调用操作阶段。这两个属性都位于同一个 bean 实例中,并在调用操作方法之前不久进行复制。这毫无意义。您似乎期望在显示表单的请求期间评估
value
。您似乎认为
设置请求参数。这不是真的。
是唯一执行此操作的函数。因此,这应该
与
faces-conig.xml
中gestionnaireMessagesController
的
上的以下内容结合使用:(如有必要,您可以删除
ARejouer
以便它重用相同的属性)You're basically doing:
during the invoke action phase of the form submit. Both properties are in the same bean instance and copied shortly before action method is invoked. This makes no sense. You seem to be expecting that the
value
is evaluated during the request of displaying the form. You seem to be thinking that<f:setPropertyActionListener>
sets a request parameter. This is not true. The<f:param>
is the only which does that.So, this should do,
in combination with the following on
<managed-bean>
ofgestionnaireMessagesController
infaces-conig.xml
:(you can if necessary remove
ARejouer
so that it reuses the same property)我经常遇到这个问题,当有两个
f:setPropertyActionListener
时就会出现这种情况。您可以这样尝试:
阅读此链接: http://www .coderanch.com/t/211274/JSF/java/Passing-param-commandLink
I have often encountered this problem , it occours when there are two
f:setPropertyActionListener
.You try in this way:
Read this link: http://www.coderanch.com/t/211274/JSF/java/Passing-param-commandLink