0
votes

I am new in Spring web flow . I have list of objects and i am showing list using tag on the webpage. In a row i have two buttons. on click of buttons i am passing object name like _eventId_showVideo value=${row.name} . By this way showVideo event contain the name of the object. similarly with the second button. both button are calling the same method.one is used for playing .bin video and second is used for playing .mov formatted video.

now i want to differentiate the button event that means from which button click method is called? can i pass the string value like ("mov" or "bin" )that we can get on the controller method? so that i can check that string is "mov" or "bin".

1

1 Answers

0
votes

You can get the event triggered by RequestContext. You don't have to pass any parameters on submit for this.

If the buttons are specified in view as:

    <input type="submit" name="_eventId_showVideo1" value="${row.name}"/>
    <input type="submit" name="_eventId_showVideo2" value="${row.someOtherName}"/>

In your flow xml for the view, pass the flowRequestContext as:

    <transition on="showVideo1" to="doSomething1">
        <evaluate expression="classForThisFlow.commonMethodName(flowRequestContext,flowScope.yourForm)"/>
    </transition>
    <transition on="showVideo2" to="doSomething2">
        <evaluate expression="classForThisFlow.commonMethodName(flowRequestContext,flowScope.yourForm)"/>
    </transition>

Your method as:

    public void commonMethodName(RequestContext context, YourForm yourForm){
        String event = context.getCurrentEvent().getId();
        if(event.equals("showVideo1")){
            //your code 
        }else if(event.equals("showVideo2")){
            //your code
        }else{
            //your code
        }   
    }

Hope this helps.