Spring Webflow: How to to customize externalRedirect in end-state? - spring-webflow-2

The parent flow of my webflows has the following end-state defined:
<end-state id="endState" view="externalRedirect:contextRelative:index.html"/>
This will redirect to http://server/context/index.html
All my flows are now configured to run in an "embedded" mode (no menus/header/etc.) if the context path contains /embedded (I implemented this by using my own ViewResolver and different tiles layouts). Example: http://server/context/embedded/page.htm uses the same flow as http://server/context/page.htm but with a different layout.
When the site is running in "embedded" mode I want the end-state to redirect to http://server/context/embedded/index.html.
How can I customize this to rather use externalRedirect:contextRelative:embedded/index.html when the the URI contains /embedded?

You could determine the embedded state from a managed bean and use EL to determine a path:
externalRedirect:contextRelative:#{myBean.getPath()}

Related

MVCActionCommand vs MVCResourceCommand

I cant see the difference between MVCActionCommand vs MVCResourceCommand in coding OSGI portlets. The two interfaces seem to be interchangeable. With ActionResponse you can jump to a URL. With ResourceResponse, I can set the content to view the content on the page.
If i need to refresh the content on the page i.e refresh a particulat , should I use ActionReponse ? Most of the examples i found on the net make use of ResourceResponse resourceResponse.getWriter().write("Success");
How do I know when to use ResourceResponse and not ActionResponse?
Many thanks.
The origin of the separation lies within the Java Portlet LifeCycle (JSR 286). The command interfaces allow hooking into the lifecycle phases and provide the execution of your custom code.
There are three very different (in purpose) portlet url handlers:
MVCActionCommand to execute command, to change data, to perform actions (and do not return any to the frontend)
MVCRenderCommand to provide presentation & view to the client, to view results from a model selection, to render data through jsp/jsf/etc
MVCResourceCommand to provide the content in response: download files, download json csv excel pdf ...

Pass parameters to a computed custom control

I'm using the xp:include tag for displaying custom controls according business rules.
I configured my custom controls with parameters (the custom prperties) that I used through the compositeData syntax.
My question is :
How can I declare the computed xpages for passing arguments to my custom control ?
Switch control or Dynamic Content Control may be a better option to choose. The difference is Switch control loads all facets into the component tree, Dynamic Content Control only loads the current facet to be displayed. So if they're specific to different parts in the business process, Dynamic Content Control may be more suitable.
Alternatively, use different XPages for different stages in the business process. With XPages links from views can be computed to go to a specific XPage rather than a single one defined for the form.

Passing properties to a custom control using xp:include

When using an Include Page to dynamically load a custom control onto an XPage, is there a way to pass custom property values to the custom control as part of the include?
Peter, the include page doesn't load a custom control but another XPage. Pages don't have properties. However... the page becomes part of the component tree, so you have access to its contained controls using getComponent("thecomponent").getParameterMap (Off my head, might be called slightly different)
Does that help?

Is it possible to use a common resource in an non-themed view?

I am using orchard cms v 1.4 and developing some site content that is stand alone and does not use the standard theme. I would like to use some of the resources already declared in manifest files on the non-themed views. However they only render when I apply a theme to the controller or the specific view.
In my view I am including the following:
#{
Script.Require("jQuery").AtHead();
}
This only functions as expected when I include: [Themed]
as an attribute on my controller.
Any idea's on how to get this to work without creating a full theme for my stand alone pages?
Yes, see http://weblogs.asp.net/bleroy/archive/2012/10/20/writing-an-unthemed-view-while-still-using-orchard-shapes-and-helpers.aspx
What's important is that you use a shape as the model. Themed or not doesn't matter then.

When to use NavigationHandler.handleNavigation vs ExternalContext.redirect/dispatch

It would seem that the following are equivalent:
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation("/index.xhtml?faces-redirect=true");
FacesContext.getCurrentInstance().getExternalContext().redirect("/testapp/faces/index.xhtml");
Are there any differences and when should each be used?
With the NavigationHandler#handleNavigation() approach you're dependent on the implemented navigation handlers. You or a 3rd party could easily overridde/supply this in the webapp. This can be advantageous if you want more fine grained control, but this can be disadvantagrous if you don't want to have external controllable influences at all. Using certain URLs and/or parameters could potentially result in a different navigation behaviour.
The ExternalContext#redirect() delegates under the covers immediately to HttpServletResponse#sendRedirect(), without involving any navigation handler. So that may be an advantage when using the navigation handler is potentially disadvantageous. But the disadvantage is that it doesn't handle implicit navigation nor takes definied navigation cases into account.
All in all, it depends :) If you just want a fullworthy and to-the-point redirect, use the ExternalContext#redirect(). If you want to navigate by an outcome instead of an URL, use NavigationHandler#handleNavigation().
See also:
What is the difference between redirect and navigation/forward and when to use what?
How to navigate in JSF? How to make URL reflect current page (and not previous one)

Resources