Announcement Announcement Module
Collapse
No announcement yet.
Generated menu by using transitions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generated menu by using transitions

    Hello everyone!

    I wanna generate a menu for my webapp by using the data of the webflow. The idea is that I mark some transitions by a suffix (e.g. _MM).

    <view-state id="viewCatalogue" view="catalogue">

    <transition on="viewTable_MM" to="decTable" />
    <transition on="viewJournal" to="viewJournal" />
    <transition on="viewReport" to="decReport" />

    </view-state>
    I created a listener which should get the data. While debugging I found out that the StateDefinition viewState has all transitions. But I got no access to the appropriate collection. I tried to do this by using the Reflection API (I never used this API unitl now). In this case a NoSuchFieldException throws.

    @Component
    public class FlowmenuListener extends FlowExecutionListenerAdapter {

    @Override
    public void viewRendering(RequestContext context, View view,
    StateDefinition viewState) {

    try {
    Field f = viewState.getClass().getDeclaredField("transitions ");
    } catch (SecurityException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (NoSuchFieldException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }
    }
    Another think is that my debugger shows “com.sun.jdi.InvocationException occurred invoking method.” when I click on parameters of the viewRendering-method.


    Thanks

    Chris

  • #2
    Try casting the viewState to TransitionableState to see if you can access the transition definitions. Also you could consider using an attribute on the transition rather than a suffix:

    Code:
    <transition on="viewTable" to="decTable"/>
      <attribute name="menu"/>
    </transition>
    Code:
    public void viewRendered(RequestContext context, View view, StateDefinition viewState) {
      TransitionableState transitionableState = (TransitionableState)viewState; 
      TransitionDefinition[] transiations = transitionableState.getTransitions();
      for(TransitionDefinition transiation: transiations) {
        if(transition.getAttributes().contains("menu")) {
          //Add to menu
        }
      }
    }

    Comment

    Working...
    X