user1155101
user1155101

Reputation: 11

How to link an action from javascript with spring web flow and jsf?

I have a requirement where in from h:commandlink or a4j:commandlink using onclick event, I need to call plain javacript function (not using any javascript framework) which inturn needs to call the required action defined in spring's web flow flow.xml.

In other works,

This works fine for me:

Process: 1:


demo.xhtml:

<h:commandLink value="link next page" action="next"/>

spring-web-flow.xml

<view-state id="demo"> <transition from="next" to="nextPage"/> </view-state>


Requirement:My need is to use something link this in javascript:


demo.xhtml:

<h:commandLink value="link next page" onClick="navigatePage();"/>

<script type="text/javascript"> function navigatePage(){

// some way to call the action="next" (as mentioned above) which will call the spring-web-flow transition.

}

Anyone if have come across such kind of solution then please help me.

Thanks in advance

Upvotes: 0

Views: 3784

Answers (1)

rptmat57
rptmat57

Reputation: 3787

you should have access to the variable flowExecutionUrl in your page. just use that with the parameter _eventId and it should work.

so this should work:

<h:commandLink value="link next page" onClick="navigatePage('${flowExecutionUrl}&_eventId=next');"/>

<script type="text/javascript">
function navigatePage(url){
    window.location = url;
}
</script>

Upvotes: 2

Related Questions