Jsf 2 在commandLink中,我使用并在MBean中获得一个空parm
在我的jsf中,我使用:Jsf 2 在commandLink中,我使用并在MBean中获得一个空parm,jsf-2,parameters,Jsf 2,Parameters,在我的jsf中,我使用: <f:param name="parm1" value="#{templateGP01MB.stringAnnId}" /> <p:imageSwitch effect="turnDown" speed="10000"> <ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
<p:imageSwitch effect="turnDown" speed="10000">
<ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<h:commandLink value="Voir l'annonce correspondante" actionListener="#{templateGP01MB.actionListener}" action="#{templateGP01MB.action}" >
<!-- <p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" onclick="visualisationAnnonce('#{image}');" /> -->
<p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" />
<f:attribute name="attributeName1" value="#{image}" />
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
</h:commandLink>
</ui:repeat>
</p:imageSwitch>
</h:form>
在MBean VisualizationAnnoncemb.java中,我得到:
<p:imageSwitch effect="turnDown" speed="10000">
<ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<h:commandLink value="Voir l'annonce correspondante" actionListener="#{templateGP01MB.actionListener}" action="#{templateGP01MB.action}" >
<!-- <p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" onclick="visualisationAnnonce('#{image}');" /> -->
<p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" />
<f:attribute name="attributeName1" value="#{image}" />
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
</h:commandLink>
</ui:repeat>
</p:imageSwitch>
</h:form>
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, String> params = fc.getExternalContext().getRequestParameterMap();
String parm1 = params.get("parm1");
Integer integerParm1 = Integer.parseInt(parm1);
我得到了一个空指针,因为parm1=Null
<p:imageSwitch effect="turnDown" speed="10000">
<ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<h:commandLink value="Voir l'annonce correspondante" actionListener="#{templateGP01MB.actionListener}" action="#{templateGP01MB.action}" >
<!-- <p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" onclick="visualisationAnnonce('#{image}');" /> -->
<p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" />
<f:attribute name="attributeName1" value="#{image}" />
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
</h:commandLink>
</ui:repeat>
</p:imageSwitch>
</h:form>
当然,我是一个新手,我不太了解jsf lyfecycle的所有内容。
如果有人能帮助我,那就太好了:
<p:imageSwitch effect="turnDown" speed="10000">
<ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<h:commandLink value="Voir l'annonce correspondante" actionListener="#{templateGP01MB.actionListener}" action="#{templateGP01MB.action}" >
<!-- <p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" onclick="visualisationAnnonce('#{image}');" /> -->
<p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" />
<f:attribute name="attributeName1" value="#{image}" />
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
</h:commandLink>
</ui:repeat>
</p:imageSwitch>
</h:form>
提前谢谢
GLO为什么要混合f:param和f:attribute?你为什么不选一个然后用两次呢?把它们混在一起没有任何意义,我不确定这一点,但这可能是它不起作用的原因
<p:imageSwitch effect="turnDown" speed="10000">
<ui:repeat value="#{galerieFloMB.stringArray}" var="image" >
<h:commandLink value="Voir l'annonce correspondante" actionListener="#{templateGP01MB.actionListener}" action="#{templateGP01MB.action}" >
<!-- <p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" onclick="visualisationAnnonce('#{image}');" /> -->
<p:graphicImage value="/resources/images/download/#{image}" width="300" height="300" />
<f:attribute name="attributeName1" value="#{image}" />
<f:param name="parm1" value="#{templateGP01MB.stringAnnId}" />
</h:commandLink>
</ui:repeat>
</p:imageSwitch>
</h:form>