Announcement Announcement Module
Collapse
No announcement yet.
How to use javascript to invoke SWF transition ???? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use javascript to invoke SWF transition ????

    How to use javascript to invoke SWF transition ????

    I want to use javascript to invoke the SWF transition, does anyone know how to do it??

    Thanks,

  • #2
    I tried the following, it submit the follow but it didn't trigger the transition.

    function()
    {
    var formAction=document.setupTeamForm.action;
    document.setupTeamForm.action = formAction + '&_eventId=setupTeam';
    document.setupTeamForm.submit();
    }

    it does generate the correct URL \<formAction>?eXsX&_eventId=setupTeam
    but it didn't trigger/invoke the transition id="setupTeam".
    Any HELPS???
    Last edited by jackura; Jun 17th, 2011, 09:43 AM.

    Comment


    • #3
      Hello

      How to use javascript to invoke SWF transition ????
      What are you trying to do?, why call a javascript function instead of press the submit button or click a link?

      Expand your idea or requirement

      About your JS code, better if you use something like this
      document.getElementById("someId") to get your objects

      Furthermore consider work with JQuery, a robust JS/CSS solution

      Comment


      • #4
        resolved the problem.

        I used rich:tab from richfaces. I want to invoke a specific transition when an user press the tab.

        Here's the solution:

        IN XHTML FILE:
        HTML Code:
        <rich:tab selectedTab="false" label="#{resourceBundle['label.tab.teams']}" name="team" styleClass="main-tab" [B]ontabenter[/B]="setTimeout(function(){
        				   	var formAction=document.setupTeamForm.action;
        				   	document.setupTeamForm.action = formAction + '&amp;_eventId=setupTeam';
        				   	document.setupTeamForm.submit();
        				},5);">
        IN CODE (I CREATE AN EVENTIDPHASELISTENER)

        Code:
        public class EventIdPhaseListener implements PhaseListener {
        
        	/**
        	 * 
        	 */
        	private static final long serialVersionUID = -4635144229104954868L;
        
        	public void afterPhase(PhaseEvent event) {
        		if (JsfUtils.isFlowRequest()) {
        			FacesContext context = event.getFacesContext();
        			if (context.getExternalContext().getRequestParameterMap().containsKey("_eventId")) {
        				UICommand eventSource = new UICommand();
        				eventSource.setTransient(true);
        				eventSource.setParent(context.getViewRoot());
        				eventSource.setId("_eventId");
        				String eventId = (String) context.getExternalContext().getRequestParameterMap().get("_eventId");
        				eventSource.setActionExpression(convertEventIdToMethodExpression(context, eventId));
        				context.getViewRoot().queueEvent(new ActionEvent(eventSource));
        			}
        		}
        	}
        
        	public void beforePhase(PhaseEvent event) {
        		// Do Nothing
        	}
        
        	public PhaseId getPhaseId() {
        		return PhaseId.APPLY_REQUEST_VALUES;
        	}
        
        	private MethodExpression convertEventIdToMethodExpression(FacesContext facesContext, String eventId) {
        		ELContext elContext = facesContext.getELContext();
        		return facesContext.getApplication().getExpressionFactory().createMethodExpression(elContext, eventId,
        				String.class, new Class[0]);
        	}
        
        }
        thank you very much

        Comment


        • #5
          Hello jackura

          Code:
          . I want to invoke a specific transition when an user press the tab.
          Now I understand

          Thanks to you for share this code for future users with similar requirement

          Comment

          Working...
          X