Spring webflow redirect not working for Portlets - spring-webflow-2

I have to implement inter-portlet communication functionality. The functionality is as below:
1) user clicks on "save as" link on "createStep1.jsp".
2) the below mentioned webflow saveDraftStep1 is called, the draft is saved in the database.
3) user is navigated to another portlet myportlet and the successfully saved message is displayed there.
Somehow the webflow is not redirecting to the url I specify in the externalRedirect. It stays on the same page. Below is the code:
<view-state id="createStep1">
<transition on="saveDraftStep1" to="redirectView" >
<evaluate expression="myAction.bindAndValidate" />
<evaluate expression="myService.saveDraft(saveCriteria, externalContext.nativeRequest,externalContext.nativeResponse )" />
</transition>
</view-state>
<end-state id="redirectView" view="externalRedirect:http://www.google.com" />
Ideally i want to replace the google url with my portlet url e.g: localhost:8080/myportlet.

If either of those evaluate calls returns an error, the transition won't be taken. Perhaps that is what's happening?

Related

How to redirect(Bidirectional way) using pages.xml by EL methods in JSF and Seam project?

I'm facing a problem while rewriting the pattern in pages.xml dynamically.
I have a mainmenu and submenus on the webpage, I have a scenario like when user give's www.website.com/mainmenu/submenu1 , EL method should execute and rewrite that particular page dynamically.Because all the menus and submenu's will come from backend. Also it should work from home page when user select submenu item. I mean, it should work in both the ways(bidirectional).
Critical part is, how to execute and get the /mainmenu/submenu names from backend when user enter's url in address bar. This must use pages.xml only by using seam framework.
Thanks in advance!! Please let me know if my explanation is not clear.
Try reading the seam docs....
<page view-id="/yourPage.xhtml">
<rewrite pattern="/{mainmenu}/{submenu}"/>
<param name="mainMenu" required="true" value="#{yourBean.mainMenu}"/>
<param name="subMenu" required="false" value="#{yourBean.submenu}"/>
<action execute="#{yourBean.processPage}" on-postback="false"/>
</page>
SEAM Documentation

Rewriting URLs using pretty-config

I am facing problem with rewriting urls using pretty-config.xml and I want help. This is what I want.
I want to render the URL as:
http://www.example.com/{productId}
and the page actual URL is:
http://www.example.com/page/product.jsf
In short, I have one page but I want to render it each time as different url based on product id from the backing bean.
Sounds fairly simple. I would use this:
<url-mapping>
<pattern value="/#{productId}" />
<view-id value="/pages/product.jsf" />
</url-mapping>
Just make sure that you generate the correct links in your pages upon rendering.

Add a global Jsp to include in Liferay tomcat-6

I have a Jsp that dynamically needs to get included in entire project as user opens any jsp. i.e. As a user opens a jsp my jsp should automatically gets included.
I have written this in web.xml in Tomcat
<jsp-property-group>
<url-pattern>/webapps/ROOT/html/*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<el-ignored>false</el-ignored>
<scripting-invalid>false</scripting-invalid>
<is-xml>false</is-xml>
<include-prelude>/WEB-INF/jsp/tracker.jsp</include-prelude>
<!-- <include-coda>/template/coda.jspf</include-coda> -->
</jsp-property-group>
I had kept my jsp in tomcat under WEB-INF/jsp/ and i want to include it into every porject as it contains a code that tracks log for user.
Or any other way to make this happen.
Thanks.
There is one more way to include your JSP for the whole portal and i.e. the dockbar.
You can create a hook and include your jsp in the /html/portlet/dockbar/view.jsp using either <jsp:include /> or <liferay-util:include /> or simple <%# include file="" /> (this would be static).
<jsp:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<liferay-util:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<%# include file="/jsp/yourJSPPageToBeIncluded.jsp" />
Note: the path may differ depending on where you will be putting the JSP.
Why I am choosing dockbar is because it is present on all the portal-pages of liferay. This won't work if you are opening a pop-up like configuration pop-up or look-and-feel pop-up or other custom dialog pop-ups since dockbar is not present in the pop-up. For using in pop-ups you would have to override portal_pop_up.vm in your custom-theme and write the code as suggested by #VikasV
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
There are two ways for this.
Simple way is to include your JSP in the Theme. When your Theme is applied to your project, and when Theme is rendered, any pages in your project will render this included JSP.
Code sample below. This has to be placed in vm file(navigation.vm).
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
Here, JSP folder is placed directly inside Theme war.
Other way (tedious one), is to include this JSP in each and every JSP page that you want this to be included.
Use <jsp:include> element for this.
Some references,
Ref1
Ref2

Redirect from error page when there are no errors to display

I want my error page of my seam application to redirect to the home page if there is no error message to display (such as if the user bookmarks the error page).
I have a number of rules in pages.xml that direct to an error page like this:
<!-- pages.xml -->
<exception class="org.jboss.seam.framework.EntityNotFoundException"
log-level="warn">
<redirect view-id="/error.xhtml">
<message severity="warn">#{messages['jsf.RecordNotFound']}</message>
</redirect>
</exception>
After trying some unsuccessful EL expressions to try to check for no messages, I added a backing bean to do the check:
<!-- pages.xml -->
<page view-id="/error.xhtml">
<action execute="#{facesMessagesUtil.getGlobalMessagesCount()}" />
<navigation>
<rule if-outcome="none">
<redirect view-id="/home.xhtml"/>
</rule>
</navigation>
</page>
.
//FacesMessagesUtil.java
import javax.faces.context.FacesContext;
import org.jboss.seam.faces.FacesMessages;
...
public String getGlobalMessagesCount()
{
log.info("currently {0} global facesMessages (seam)", FacesMessages.instance().getCurrentGlobalMessages().size());
log.info("found messages in faces context: {0}", FacesContext.getCurrentInstance().getMessages().hasNext());
log.info("got maximum severity: {0}", FacesContext.getCurrentInstance().getMaximumSeverity());
if (!FacesContext.getCurrentInstance().getMessages().hasNext())
{
return "none";
}
return "some";
}
The above method is invoked when I manually generate an error, but this redirects to home and shows the error message there. The log messages report that the classes I'm using don't seem to have any visibility of the message that is being displayed:
16:41:41,908 INFO [FacesMessagesUtil] currently 0 global facesMessages (seam)
16:41:41,908 INFO [FacesMessagesUtil] found messages in faces context: false
16:41:41,908 INFO [FacesMessagesUtil] got maximum severity: null
Is there a class in seam 2 that will allow me to check if there are any messages?
Is there an EL expression that can do this check without an extra bean?
As best I can deduce with my investigations so far, the problem here is with how seam forwards FacesMessages from one JSF context to another. Essentially the messages appear to have been removed to some other seam component while pages.xml rules are being applied, then returned by the time the page is rendering. I have worked around this issue for now by showing a 'no errors' message (note that global messages are present during page render):
<h:outputText id="noErrorsMessage"
rendered="#{empty org.jboss.seam.international.statusMessages.currentGlobalMessages}">
#{messages['jsf.NoErrors']}
</h:outputText>
and with some hard-coded redirect rules in one of my beans.

SharePoint BCS creating a hyperlink column

I am using the .NET connector to connect to an SQL database. One of this value is a URL. Now I need to display this as a URL.
Any ideas on how to solve this?
In Sharepoint Designer you can edit the read list and go to the field, so for example you have a field called URL, display it as a label so it would render like
<asp:Label runat="server" id="ff1{$ID}" text="{$thisNode/#URL}" />
Then all you need to do is add an "A href" tag to it so it renders as a url like such
<asp:Label runat="server" id="ff1{$ID}" text="{$thisNode/#URL}" />

Resources