开发者

Javascript calling JSF handler method

I am reading an xml file using javascript and then I need to submit my form so that it calls a particular method in my JSF handler. Usually this can be done on a jsp when user clicks a button by having an actionlistener like so:

<h:commandLink styleClass="button" action="#{myHandler.outcome}" actionListener="#{myHandler.doNext}">
    <span><h:outputText value="#{text.button_submit}" /></span> </h:commandLink>

I am not sure how to call a method like 'doNext' above in the handler from javascript. I cannot do开发者_JS百科 a simple:

document.form.submit();

as it then repeats the processing i have already done. I want to read values from an xml file and then call a particular method in handler. Any ideas much appreciated.


I found a solution to this. I added a hidden button to my jsp like:

<p id="hiddenButton" style="display:none;" >
           <h:commandLink id="hiddenRegButton" styleClass="button" action="#{myHandler.doNext}" />
        </p>

and in my javascript I used jQuery to execute the click which leads t the "doNext" method in my Handler to get executed.

jQuery('#hiddenRegButton').click();

this was easier than I thought.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜