简体   繁体   中英

Primefaces Calendar <f:ajax> and <p:ajax> issue

I am currently facing issue using with primefaces Calendar control

My requirement is to invoke a java method on change of the Calendar control value either from the input box or using the button and also pass a set of parameters(Java object and the field id) to the java method.

below is the code that I have implemented and it is not working

<p:calendar showOn="button" id="effectiveDt" navigator="true" pattern="MM/dd/yyyy" 
    styleClass="overrideable" value="#{coverage.startDate}">
    <f:ajax event="change" render="hiddenStartDt" onevent="myEvent" listener="#{certInquiry.ovrrrideListener}"/> 
        <f:attribute name="covg" value="#{coverage}" />
        <f:attribute name="field" value="StartDate" />
</p:calendar>

here myEvent is a java script method which will be called after the ajax is completed where i am checking the ajax status is success and performing some action.

method signature of the java method is.

* public void overrideListener(AjaxBehaviorEvent e) *

I tried with all kinds of methos signatures like

public overrideListener(ValueChangeEvent e)
 public overrideListener(ActionEvent e)
 public ovrrrideListener(DateSelectEvent event)

nothing was working for me

I have tried using also even this was not working I also tried using valueChangeListener if the method gets called but it was not invoking the method

this is working for and fields using the

<h:selectBooleanCheckbox class="overrideable" 
                    value="#{coverage.clIndicator}">
    <f:ajax event="change" render="hidgenLiabClaimsMdInd" onevent="myEvent" listener="#{certInquiry.overrideListener}"/> 
                    <f:attribute name="covg" value="#{coverage}" />
                    <f:attribute name="field" value="ClIndicator" />
</h:selectBooleanCheckbox>

<h:inputText id="genLiabEachOccAmt" value="#{coverage.eachOccAmt}"
            class="amt_field overrideable">
    <f:ajax event="change" render="hidgenLiabEachOccAmt" onevent="myEvent" listener="#{certInquiry.overrideListener}"/> 
            <f:attribute name="covg" value="#{coverage}" />
            <f:attribute name="field" value="EachOccAmt" />
</h:inputText>

Please help me in solving this issue for the Calendar component.

进行ajax event="dateSelect" ,当您使用ovrrrideListener(DateSelectEvent event)时,应该在BB中获取日期值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM