2

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 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.

1
  • I resolved this issue by placing a hidden button on the form and then in my javascript I simply called button.click() which executed the actionListener associated with that button. So I basically just imitated the button click in javascript. Commented May 13, 2010 at 19:14

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.