在c:forEach循环中使用p:commandLink将参数传递给actionListener方法 [英] Passing argument to actionListener method with p:commandLink inside c:forEach loop
本文介绍了在c:forEach循环中使用p:commandLink将参数传递给actionListener方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对话框,其中包含命令链接内的图形图像列表.单击命令链接时,我想将图像名称作为操作侦听器方法参数传递.
I have a dialog that contains a list of graphic images inside command links. When a command link is clicked, I want to pass the image name as action listener method argument.
对话框的代码:
<p:dialog id="idSchemaDlg5" widgetVar="schemaDlg" styleClass="maxSizeDialog" position="90,250" style="max-width:1000px;max-height: 1000px;" header="Schéma des circuits">
<c:forEach id="schemaDataGrid" items="#{historyGenerationBean.schemaList}" var="fileCircuits" varStatus="schemaNum">
<h:panelGrid columns="1">
<h:outputText value="SiteG2R #{historyGenerationBean.g2rNames.get(schemaNum.index)}" style="font-family: Tahoma, Geneva, sans-serif;color: #ED7905;font-size: 16px;font-weight: bold;"/>
<c:forEach items="#{fileCircuits}" var="pictureNamesList">
<h:panelGrid columns="#{pictureNamesList.size()}">
<c:forEach items="#{pictureNamesList}" var="imageName">
<h:form>
<h:panelGroup style="width:6px">
<p:commandLink actionListener="#{historyGenerationBean.fetchMlpppInformation(imageName)}" >
<p:graphicImage value="#{imageStreamer.image}" >
<f:param name="imgName" value="#{imageName}" />
</p:graphicImage>
</p:commandLink>
<h:outputText value="#{imageName}" style="width:50%; font-family: Tahoma, Geneva, sans-serif; font-size:70%;color:black;background-color:transparent;text-align:left;"/>
</h:panelGroup>
</h:form>
</c:forEach>
</h:panelGrid>
</c:forEach>
</h:panelGrid>
</c:forEach>
</p:dialog>
将调用动作侦听器方法,但是我没有收到参数imageName
.是null
.
The action listener method is invoked, however I don't receive the argument imageName
. It is null
.
@ManagedBean(name = "historyGenerationBean")
@RequestScoped
public class HistoryGenerationBean implements Serializable {
@PostConstruct
public void init() {
String[] listRegion = new String[6];
circuitMlpppMap = new HashMap<>();
listRegion[0] = "Centre-Est";
regionOptions = createFilterOptions(genBean.getListRegion());
if (loginBean.connectedUserHasRole("ADMIN")) {
histories = generationHistoryFacade.findAll();
} else {
histories = loginBean.getConnectedUser().getGenerationHistoryList();
}
history = new GenerationHistory();
}
public void fetchMlpppInformation(String imgName) {
System.out.println("l'image sélectionnée est: " + imgName);
}
}
我该如何解决?
推荐答案
我找到了使用.
<p:dialog id="idSchemaDlg5" widgetVar="schemaDlg" styleClass="maxSizeDialog" position="90,250" style="max-width:1000px;max-height: 1000px;" header="Schéma des circuits">
<h:form id="schemaFormId" dir="#{login.dir}">
<ui:repeat value="#{historyGenerationBean.schemaList}" var="fileCircuits" varStatus="schemaNum">
<ui:repeat value="#{fileCircuits}" var="pictureNamesList">
<table>
<tbody>
<tr>
<ui:repeat value="#{pictureNamesList}" var="imageName">
<td>
<h:panelGrid columns="1">
<p:commandLink action="#{historyGenerationBean.fetchMlpppInformation}" update=":schemaFormId" >
<p:graphicImage value="#{imageStreamer.image}">
<f:param name="imgName" value="#{imageName}" />
</p:graphicImage>
<f:param name="imgName2" value="#{imageName}" />
</p:commandLink>
<h:outputText value="#{imageName}" style="width:50%; font-family: Tahoma, Geneva, sans-serif; font-size:70%;color:black;background-color:transparent;text-align:left;"/>
</h:panelGrid>
</td>
</ui:repeat>
</tr>
</tbody>
</table>
</ui:repeat>
</h:form>
</p:dialog>
非常感谢帮助我的所有人(@BalusC也是如此).
Many thanks to everyone who helped me(@BalusC too).
这篇关于在c:forEach循环中使用p:commandLink将参数传递给actionListener方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文