Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Creation of breadcrumb links in FlowExecutionListener

  1. #1
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default Creation of breadcrumb links in FlowExecutionListener

    Hi,

    I would like to generate a breadcrumb navigation bar showing active flows and subflows. I want to display this on all pages (view states).

    FlowExecutionListener seems to be a good place for this, but I need to have 2 pieces of information: flowExecutionId (used for the generated anchors) which is accessible only in saved() method and also requestScope where I want to place the generated navigation to be accessible for the pages, but I cannot find a way how to access the requestScope in saved() of FlowExecutionListener.

    RequestScope is easily reachable in stateEntered() but here I don't have access to the flowExecutionId (doesn't exist yet) which will be used in views.

    Is there a way how to do this or a new callback method should be added to the FlowExecutionListener which would be called just before the control si passed to a view and its parameters would contain requestContext (which would already contain the flowExecutionId at the moment).

    Thanks,
    Karel

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    would

    Code:
    public void requestSubmitted(RequestContext context);
    not be better, or event

    Code:
    public void requestProcessed(RequestContext context);

  3. #3
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default

    Unfortunatelly not. requestSubmitted() is called too soon (before state transition and new flowExecutionId creation) and requestProcessed() seems to be called too late (after the view has been rendered)

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    You could override FlowExecutionManager prepareViewDescriptor.

    We might want to add a FlowExecutionListener.viewReturning callback, given you access to put stuff in the selected and prepared ViewDescriptor, where you could put whatever you wanted in the model Map.
    Keith Donald
    Core Spring Development Team

  5. #5
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    kajism.

    My bad

  6. #6
    Join Date
    Aug 2004
    Location
    Brno, Czech Republic
    Posts
    48

    Default

    Thanks for your help guys.

    Keith, the FlowExecutionListener.viewReturning() callback would be definitely usefull.
    In addition, please, the addSubflowState() methods of AbstractFlowBuilder should probably return the created SubflowState (as usual for the other addXXX methods in the builder) instead of void.

    Thanks a lot,
    Karel

  7. #7
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    You could also just do it with a custom JSP tag in the JSP itself. Remember that except for the "flowExecutionId" and "currentStateId", also the FlowExecutionContext" is available to the view using the "flowExecutionContext" attribute. The FlowExecutionContext gives you access to all information you need to generate a breadcrumbs kind of thing (e.g. getFlowSession(), getFlowSession().getParent(), getFlowSession().getCurrentState(), ...) and ofcourse you already have the flow execution id.

    Erwin

  8. #8
    Join Date
    Nov 2004
    Location
    Austin, Texas USA
    Posts
    46

    Default

    Thought it might be worth sharing my implementation of a breadcrumb trail based on flow hierarchy. This FlowExecutionListenerAdapter builds a List of strings (one per crumb) and places it into the request context under the key "breadcrumbs".

    Note that flow names don't always provide the most meaningful breadcrumb text. I'm using a MessageSource to lookup localized breadcrumb strings.

    A flow can be omitted from the breadcrumb trail by assigning it an empty name in the message source.

    Code:
    public class BreadcrumbFlowExecutionListener extends FlowExecutionListenerAdapter {
    
        protected MessageSource messageSource;
    
        public void setMessageSource(MessageSource messageSource) {
            this.messageSource = messageSource;
        }
    
        public void stateEntering(RequestContext ctx, State state) throws EnterStateVetoException {
            if (state instanceof ViewState) {
                FlowSession session = ctx.getFlowExecutionContext().getActiveSession();
                List crumbs = new ArrayList();
                Map scopeMap = session.getScope().getAttributeMap();
                crumbs.add(getLocalizedFlowName(scopeMap, session.getFlow().getId()));
                while (session.getParent() != null) {
                    session = session.getParent();
                    scopeMap = session.getScope().getAttributeMap();
                    String flowName = getLocalizedFlowName(scopeMap, session.getFlow().getId());
                    if (flowName != null && !flowName.equals(""))
                        crumbs.add(0, flowName);
                }
                ctx.getRequestScope().setAttribute("breadcrumbs", crumbs);
            }
        }
    
        public String getLocalizedFlowName(Map attributeMap, String flowId) {
            return attributeMap, messageSource.getMessage(flowId, new String[0], flowId, Locale.getDefault());
        }
    }

  9. #9
    Join Date
    Dec 2006
    Posts
    3

    Default how to implement breadcrumb

    Hi,

    I am in a need to implemnt breadcrumb in my project. we are using springframework1.2.8. I knew that for implementing breadcrumb we need to have FlowExecutionListenerAdapter class for which webflow-support.jar which is not present in spring1.2.

    Is it still possible to do breadcrumb with spring1.2.8. Kindly help me and tell me the procedure to do that

  10. #10
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    The FlowExecutionListenerAdapter is part of Spring Web Flow (SWF), which is a subproject of Spring proper. This thread describes how to do breadcrumbs in SWF.

    Check http://www.springframework.org/webflow for details.

    Erwin

Similar Threads

  1. Replies: 1
    Last Post: Oct 19th, 2005, 05:14 AM
  2. Replies: 2
    Last Post: Aug 2nd, 2005, 02:06 AM
  3. Dynamic Bean Creation?
    By Michael Kastner in forum Container
    Replies: 3
    Last Post: Jun 27th, 2005, 06:42 PM
  4. Replies: 1
    Last Post: Aug 20th, 2004, 11:11 AM
  5. Configure a bean after creation
    By ndlesiecki in forum Container
    Replies: 2
    Last Post: Aug 16th, 2004, 11:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •