Java 将参数传递给OverlyPanel jsf2

Java 将参数传递给OverlyPanel jsf2,java,jsf,primefaces,Java,Jsf,Primefaces,我将spring与JSF-2和primefaces一起使用 我在Filiale和Commentaire之间有OneToMany关系。 我需要添加Commentaire。 但我无法通过分公司的id 我有以下代码: 您的idFiliale对象必须有一个getter和setter。然后你可以做: <h:commandButton type="submit" value="Ajouter Commentaire" action="#{commentaireBean.addComment

我将spring与JSF-2和primefaces一起使用

我在
Filiale
Commentaire
之间有
OneToMany
关系。 我需要添加
Commentaire
。 但我无法通过分公司的
id

我有以下代码:


您的
idFiliale
对象必须有一个getter和setter。然后你可以做:

<h:commandButton type="submit" value="Ajouter Commentaire"
    action="#{commentaireBean.addCommentaire(idFiliale)}" >
  <f:setPropertyActionListener value="#{idFiliale}" target="#{filialeBean.idFiliale}"/>
</h:commandButton>


不要将跟踪作为注释发布,而是在您的帖子中编辑。完成后,这是我在StackOverflow中的第一个问题谢谢您我在作用域变量中测试了您的答案我有idfiliale,但我有以下错误:/pages/FilialDetails.xhtml@61,88标记库支持命名空间:,但是没有为名称定义标签:SerPropertyActionListener对不起,我在手机上写下了答案,我的意思是说
f:setPropertyActionListener
<p:commandButton id="commentBtn" value="Dynamic" type="button" >
<p:overlayPanel id="commentPanel" for="commentBtn" hideEffect="fade" dynamic="true" style="width:600px">

    <p:panel header="Nouveau Commentaire" style="width:450px;height:250px;border:none;font-size:small;padding:0px;" >

        <h:form>
             <p:panelGrid columns="2" cellpadding="2">
                <h:outputLabel for="date" value="Date:" />
    <p:calendar id="date" value="#{commentaireBean.comment_date}" pattern="dd-MM-yyyy" mask="true" />

                <h:outputText for="text" value="Commentaire:" />

    <h:inputTextarea value="#{commentaireBean.comment_text}"></h:inputTextarea>

                <h:commandButton type="submit" value="Ajouter Commentaire"
                    action="#{commentaireBean.addCommentaire(idFiliale)}" >
                    <f:param  name="idFiliale" value="#{idFiliale}"></f:param>
                    </h:commandButton>
            </p:panelGrid>
        </h:form>
    </p:panel>
</p:overlayPanel>
</h:form>



@Component("commentaireBean")
@Scope("session")
public class CommentaireBean {

    @Autowired
    private CommentaireService commentService;

    @Autowired
    FilialeService filialeService;

String idfiliale= (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("idFiliale" );

public void addCommentaire(Long filiale_id){
        commentaire = new Commentaire();
             commentaire.setComment_text( getComment_text() );

             Long id = Long.parseLong(idfiliale);
             System.out.println("id" + id);

             commentaire.setFiliale( filialeService.getFiliale(id ));
            commentaire.setComment_date( comment_date );
          System.out.println("avant d'ajourer");
             commentService.addCommentaire( commentaire );
             System.out.println("après d'ajourer");

             FacesMessage message = new FacesMessage( "Ajout de commentaire reussi!" );
             FacesContext.getCurrentInstance().addMessage( null, message );
              }
}
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:453)
at java.lang.Long.parseLong(Long.java:483)
at com.ant.pbacklog.managedbean.FilialeBean.getFiliale_id(FilialeBean.java:102)
at com.ant.pbacklog.managedbean.FilialeBean.getCommentaires(FilialeBean.java:227)
<h:commandButton type="submit" value="Ajouter Commentaire"
    action="#{commentaireBean.addCommentaire(idFiliale)}" >
  <f:setPropertyActionListener value="#{idFiliale}" target="#{filialeBean.idFiliale}"/>
</h:commandButton>