JSF 2.2 ViewScoped bean behaving as if it were SessionScoped bean in WebSphere Portal - jsf-2

I'm working on a project, which uses JSF 2.2 in a "WebSphere Portal" environment.
I am having strange behavior with ViewScoped beans.
Suppose I have two pages in my Portal, one called "A" and one called "B".
On my "A" page there is a portlet that has a screen with a list of Ajax paging items. Suppose I click to go to page 2 in this list of items and I navigate to the "B" page in the Portal.
The expected behavior of a ViewScoped bean is that when we leave the page the bean is destroyed, and when we return the bean is constructed, restarting all the data, that is, losing the state.
However, when I navigate to page "A" again, the current page of the portlet screen pagination is at 2, that is, kept the state, even though I navigated to another page.
WebSphere Portal 9.0
JSF 2.2
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>GSRE-GestaoUsuarios-Portlet</display-name>
<context-param>
<description>
Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
JSF runtime will be loaded and initialized when the first JSF request is processed.
This may disable custom JSF extensions, such as factories defined in the project.</description>
<param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>com.ibm.faces20.portlet.httpbridge.PortletRequestAttributesListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<enabled>true</enabled>
<async-supported>false</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
<view-handler>com.ibm.faces20.portlet.FaceletPortletViewHandler</view-handler>
<el-resolver>com.ibm.faces20.portlet.PortletELResolver</el-resolver>
<resource-handler>com.ibm.faces20.portlet.httpbridge.PortletResourceHandler</resource-handler>
</application>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletActionURL</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletActionURL</component-class>
</component>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletResourceURL</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletResourceURL</component-class>
</component>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletRenderURL</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletRenderURL</component-class>
</component>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletParam</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletParam</component-class>
</component>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletProperty</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletProperty</component-class>
</component>
<component>
<component-type>com.ibm.faces20.portlet.component.PortletNameSpace</component-type>
<component-class>com.ibm.faces20.portlet.component.PortletNameSpace</component-class>
</component>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>com.ibm.faces20.portlet.tag.render.ActionURLTagRender</renderer-type>
<renderer-class>com.ibm.faces20.portlet.tag.render.ActionURLTagRender</renderer-class>
</renderer>
</render-kit>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>com.ibm.faces20.portlet.tag.render.ResourceURLTagRender</renderer-type>
<renderer-class>com.ibm.faces20.portlet.tag.render.ResourceURLTagRender</renderer-class>
</renderer>
</render-kit>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>com.ibm.faces20.portlet.tag.render.RenderURLTagRender</renderer-type>
<renderer-class>com.ibm.faces20.portlet.tag.render.RenderURLTagRender</renderer-class>
</renderer>
</render-kit>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>com.ibm.faces20.portlet.tag.render.PortletNameSpaceTagRender</renderer-type>
<renderer-class>com.ibm.faces20.portlet.tag.render.PortletNameSpaceTagRender</renderer-class>
</renderer>
</render-kit>
</faces-config>
How to make the #ViewScope scope work as expected, ie both page refresh and browser refresh destroy and build the bean.

Related

Calling static method from JSF page [duplicate]

Im new to JSF 2. My question is related to BalusC's answer to this question jsf2 ajax update parts based on request parameters I tried the kickstart code BalusC posted and I encountered an EL parsing error:
/nameofpage.xhtml #12,64 rendered="#{bean.panels.contains('u1')}"
Error Parsing: #{bean.panels.contains('u1')}
I guess that this is caused because I'm not running a Servlet 3.0 / EL 2.2 capable container with a /WEB-INF/web.xml declared as per Servlet 3.0 spec. I'm using Tomcat 6.
BalusC suggested in his answer to create a custom EL function. But how do I accomplish this using a custom EL function? Or can this be fixed by just configuring certain parts of my project?
Below is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
First create a final class with a public static method which does exactly the job you want:
package com.example;
import java.util.Collection;
public final class Functions {
private Functions() {
// Hide constructor.
}
public static boolean contains(Collection<Object> collection, Object item) {
return collection.contains(item);
}
}
Then define it as a facelet-taglib in /WEB-INF/functions.taglib.xml:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://example.com/functions</namespace>
<function>
<function-name>contains</function-name>
<function-class>com.example.Functions</function-class>
<function-signature>boolean contains(java.util.Collection, java.lang.Object)</function-signature>
</function>
</facelet-taglib>
Then familarize Facelets with the new taglib in the existing /WEB-INF/web.xml:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/functions.taglib.xml</param-value>
</context-param>
(note: if you already have the javax.faces.FACELETS_LIBRARIES definied, then you can just add the new path semicolon separated)
Then define it in the Facelets XHTML file as new XML namespace:
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:func="http://example.com/functions"
...
>
Finally you can use it as intended:
rendered="#{func:contains(bean.panels, 'u1')}"
As a completely different alternative, you can also include JBoss EL in your project. It works on Tomcat 6.0 and you'll be able to invoke non-getter methods in EL. Drop jboss-el.jar file in /WEB-INF/lib and add the following to your web.xml:
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
Since EL 2.2 there's another approach: create an #ApplicationScoped bean with methods in turn referring to those static functions. See also a.o. Utility methods in application scoped bean.

A4J Polling throws error on reREnder

I have a JSF(2.2.5) project using RichFaces(4.3.6) and PrimeFaces (5.0) with the following code
<h:panelGroup>
<a4j:region>
<h:form>
<a4j:poll id="poll" interval="15000" enabled="#{card.poll}"
reRender="swimlanes #parent" actionListener="#{card.reloadData}" />
</h:form>
</a4j:region>
<h:form>
<a4j:outputPanel id="swimlanes">
<h:panelGroup>
Stuff
</h:panelGroup>
</a4j:outputPanel>
</h:form>
</h:panelGroup>
Which is very similar to the example of the RichFaces page but when the poll becomes enabled I get the following error and no reRendering occurs
debug[09:41:56.298]: New request added to queue. Queue requestGroupingId changed to j_idt20:poll
debug[09:41:56.299]: Queue will wait 0ms before submit
debug[09:41:56.299]: richfaces.queue: will submit request NOW
info [09:41:56.302]: Received 'begin' event from <span id=j_idt20:poll ...>
info [09:41:57.310]: Received 'beforedomupdate' event from <span id=j_idt20:poll ...>
debug[09:41:57.312]: Server returned responseText: <partial-response id="j_id1"><changes><update id="j_idt20:poll"><![CDATA[<span style="display:none;" id="j_idt20:poll"><script type="text/javascript">new RichFaces.ui.Poll("j_idt20:poll",{"enabled":true,"interval":15000,"ontimer":function(event){RichFaces.ajax("j_idt20:poll",event,{"incId":"1"} )}} )</script></span>]]></update><update id="javax.faces.ViewState"><![CDATA[zl8Yr/2cJTwlpFZfrKzxi16KSE/7HTOE5e3ptnUnBJgIouLrdwKWDtUDlUWXx3gmmcCA9jCPG6jpktimoa1GPe4Icqn0EC/f4uetGoNQqAoieOT+2vVVDmQPQclPxvnaZU/3T+2fUyMU2YU5YF0C6/WrStC+UGJzhts1AIP0v6tZ2PHC5XqZhb1hpg6943W4/61rQBNNMRDYerzyipmtFkNLLQm5VtyfVqijlaQhzeP1QJeOqTDHtFAnBN78Ie6E3uGgufi8wX9jVeIXkkaI29OERWotflx2OKaJSakb/lWXMMjjU4NTejwT6IOLx2Mw5mstciSUCRMPzAbA19OK7uFh+Zun2CPRG27T3RH9je9C7iVwxjlZNXKuUhW/QlyPWoyZkhCpfp5Xxc+eruD/iAUZSJPPKQaM/OzEukNegOSeSaQJ1dLCPynuKBhrRDVyAvdR1UN2jT3G4VtK3P8YCv9p8OpwiDQAl3hUqPPrWxgR/4oIsj7Znfjp5uYZ1FDKVEHJSIYpc2tZpYFqEXr9tGjN0lqKcgrFhf3uOJAPw3PM1xhD0iBwucVYQLdT3EgCzrGLfiirzWktFwBJ5Wlo+sJLKBl02rXhV65CCqWgi9FlpzhrCMkyav0nUpF1bkXJXI0Di3jKESQnF2lWbsNN5886Aem81pu5C8tXGzK4mulnM70oTcqrBuLKBjV6sXbctKATOYNytKIQC5JOH/kt0SqU/AlAg29mVjUkBtOyW/MNKXQ3xkRf4eLDxD0KmAGfNtWRzGYSd/YBbIPERZlrRJuhQh02NugTqvsXdMhKEZmbOSU9HYOX7vbj8UzDeZiy+Kp86ZAUswZ7jbOlZOVlOPn4AJPBD51htiUtTi4zh8zbhKSOpHfvuVYqseHBKtgDi0pvPn/rNC36dbtD4sLLxFPLLinr3OGpTj4IxJRhXQvV8Sj4jUuGK3y6s2eISOU6bgsmcz8ZqLO8OnZVakVITsyqQ9Zs7OhhCks/5a2VMaKpKDKMCS9bwt3aHlK+vPogE6IngBRXCB9ow8fC6A8eLSWQanQGS3U0cqiRt8LL25vs9bDuUTaXdHpJZjOU9KqzsafAeaBdxfAidxigtvvgaMissfobFc+j3yQBcAuMEX9s1NQT3R7xuMLe7Ox62qatAAm1eJgbjezI6W6ZYO6xjL7BEHzUswaBy51hw0Ff5HRfulZrnHlzogIqcLTg+uRsRqHlXIZ3cEOXBOvG6EJChyP7eAYvwuQAEBWUjtHbJ85s5xuZUsCDMwawVwN7i7J7ToLdVfuNiAfDkhzmx8M50lkXY0+5NBT/sIROuZ2nJd3QuPpQ2+nC0KoqA4+SjDKIHpC7hVeZVYXV1NmA1uTXVE5BTMnJid+CPSv93t5rbHAOowr6BTqJGv0uKHlFTaGt7kxlWdGZgT8rqP4/f5OtrgaW7oWjbRClEyUlOMxQt0HW2LcmILLS5Vc8xNUGqjCNxC7P4hbnR3OuIMMnsMyoXZCxj++ftsrXpNtqOAE6APZv6ph8E5I2KSmNe3BJiVqjYoybbLbrfbaLcAr5uR3y53BZDyHOukm/KWzk/EfNTed7wlLvOzZ6RFKWIqycF24sXNj/9OHHAsT3U8+lWnSy3O+dC+Yk49oL8CG6pLzL3weP68ztFnbI/FqgpyVocDPRs/gvySPWNqidGJqkqArnKglDa7DeX/uL/Lf+hcvNvge8fv87/FEll6amlKvIc84YEr2JWtUsgpmr4rB1L7/HvihIyCcmZT3VoBpqzuixsGWt48mZFAcMJVPzbWbVmPu8eUitCfq94rQGU5jq7DeDT131wUHnl/T3Ylpx5pd2hd0zDClN53MnaeyAoH9u+rYaU2ilkWWn0uq9Elt7VCU1MdIHu+RNb14JwnRQNCuPrXXW7Oaz8UlTO1RIODuDLLP6oVJP9YGa3qP6U9Kws9du4iJ9LYEt5DNeZvzJSRTTYrY=]]></update><extension id="org.richfaces.extension"><render>j_idt20:poll</render></extension></changes></partial-response>
warn [09:41:57.318]: richfaces.queue: ajax submit error: During update: javax.faces.ViewState not found
debug[09:41:57.319]: richfaces.queue: Nothing to submit
error[09:41:57.320]: Received 'error#malformedXML' event from <span id=j_idt20:poll ...>
error[09:41:57.321]: [status=200] During update: javax.faces.ViewState not found
info [09:41:57.321]: Received 'complete' event from <span id=j_idt20:poll ...>
This is the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Agile Development Tools</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Any idea how to fix this please?
It's a BUG in RichFaces 4.3.7 and earlier versions!
This Bug doesn't exist in RF Version 4.5 and 5.0

Struts 2 Portlet - redirectAction not working, doView() not called

I'm trying to create a simple Struts 2 JSR 286 Portlet, running on WebSphere Portal 7. I'm able to display a simple JSP that contains a link which calls an action and displays another JSP which accepts input. That works fine.
I start to run into problems, however, when I try to use a redirectAction. I don't see any error messages, but the redirect doesn't seem to work. The Portlet just shows a blank page.
In debugging this I noticed that the doView method of my Portlet class is never called, which seems very suspicious.
If anyone has experience developing Struts 2 Portlets on WebSphere Portal, I would appreciate some help in checking that my config files are correct. Have I missed something?
Here are the details:
WebSphere Portal 7.0.0.2
WebSphere Application Server 7.0.0.25
RAD 8.0.4
Struts 2.3.14.2
Windows 7
portlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app id="com.ibm.demo.jsr286.TopUpPortlet.72594d5fe3"
version="2.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<description xml:lang="EN">Demo JSR 286 Struts Portlet</description>
<portlet-name>Demo Portlet</portlet-name>
<display-name>Demo Portlet</display-name>
<!-- DemoPortlet extends org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher -->
<portlet-class>com.demo.jsr286.DemoPortlet</portlet-class>
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>Demo Portlet</title>
<short-title>DemoPortlet</short-title>
<keywords>Demo Portlet</keywords>
</portlet-info>
</portlet>
<default-namespace>http://JSR286StrutsDemo/</default-namespace>
</portlet-app>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>JSR 286 Struts Demo</display-name>
<servlet id="Struts2PortletDispatcherServlet">
<servlet-name>Struts2PortletDispatcherServlet</servlet-name>
<servlet-class>org.apache.struts2.portlet.dispatcher.DispatcherServlet</servlet-class>
</servlet>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-plugin.xml"/>
<package name="view" extends="struts-portlet-default" namespace="/view">
<!-- This action works -->
<action name="index">
<result>/html/view/index.jsp</result>
</action>
<!-- This action works -->
<action name="startDemo">
<result>/html/view/demo.jsp</result>
</action>
<!-- This action does not work -->
<action name="redirectToIndex">
<result type="redirectAction">
<param name="actionName">index</param>
<param name="namespace">/view</param>
<param name="portletMode">view</param>
</result>
</action>
</package>
</struts>
* Update *
I've narrowed the problem down slightly. It looks like the action is being interpreted as a file location rather than a struts action. So, when I call action "redirectToIndex" it tries to display a page called "/view/index.action". I verified this by creating a file with that path and sure enough, the contents of that file are displayed in the portlet.
I feel that I'm probably missing some configuration option, but I'm not sure what. Servlet filter maybe? Can anyone help?
Actually you don't need doView method, because Jsr286Dispatcher is just a dispatcher. You can use actions like in ordinary Struts2 application.
From the documentation:
The portlet-class element is always org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher (or a subclass, if you have added some custom functionality). This is the portlet that acts as the dispatcher for the Struts 2 framework, and translates incoming user interaction to action requests that Struts 2 understands.
For jsr286 specification <portlet-class> should be org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher and defaultViewAction init-param will call Struts2 action. And in struts.xml file, like usually, you can define action class + method to call.
So you need to define Jsr286Dispatcher as <portlet-class> and create action which you will use in struts.xml action definitions.
Also see this two links: http://struts.apache.org/development/2.x/docs/struts-2-portlet-tutorial.html and http://struts.apache.org/development/2.x/docs/portlet-plugin.html.

JSF2: Tags not rendered but the usual "fixes" doesn't cut it

My problem is similar to:
JSF tags not rendered, JSf tags not being rendered and also JSF tags not being rendered as HTML no suggestion there helped me.
Basically the problem is that regardless of going through a welcome page or not the page is not rendered. IE tries to download the file and chrome basically just skips all the jsf tags. It's obvious that it wasn't translated by the framework but I don't understand why.
The back story is that I did a pilot for a conversion of a system from jsf 1.2 into jsf2. The pilot was successful I managed to get it to work in the pilot branch. However when I'm trying to achieve the same thing for real this time I can't get it to work.
The usual problem seems to be (accordingly to veteran answerer BalusC):
The page URL did not match the url-pattern of the FacesServlet, thus it had not any chance to parse the tags.
OR: The xmlns declarations for JSF components are missing in tag, thus it was treated as plaintext.
The usual fixes seems to be:
Include xmlns in html declaration (I have this in both web.xml and the .xhtml files)
Include or modify Faces Servlet Mapping in web.xml. I can however find no fault in mine. I also tried switching out /faces/* to *.xhtml. Parts that I see as relevant in web.xml included below (Whole file is big, this is a big system):
Part of web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_5.xsd"
version="2.5">
<context-param>
<description>
Tell the runtime where we are in the project development
lifecycle.
</description>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>*.xhtml</url-pattern>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<welcome-file-list id="default">
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
I'm aware that the welcome file is a html file but this worked in the pilot. That file uses
<body bgcolor="#FFFFFF" onload="window.location='portal/login/login.jsf'">
</body>
To get things going. if I manually type the adress in to some random test page containing little and simple code the problem still occurs so the problem feels unrelated to welcome page.
Will gladly assist with any additional information and I'm really stuck here in a bad spot. Thanks for reading.
Resolved by editing faces-config to include xmlns:xsi.

Calling ActionClass in tiles.xml using Struts 2.0

I reviewed the example of tiles with struts2.0 and found that in tiles.xml jsp pages are called like:
<definition name="welcome" extends="baseLayout">
<put-attribute name="title" value="Welcome"/>
<put-attribute name="body" value="/welcome.jsp"/>
BUT my question is if I want to call the action class instead of .jsp pages than how to call it like
<definition name="friends" extends="baseLayout">
<put-attribute name="title" value="Friends"/>
<put-attribute name="body" value="/checkActionLink.action"/>
when I am trying to write to execute the above code than its showing the error that checkActionLink.action is not found....thanks in advance for the help.....
Following is the web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Struts2Example15</display-name>
<servlet>
<servlet-name>tiles</servlet-name>
<servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
<init-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
After so much research I found out that adding the following tag:
<dispatcher>FORWARD</dispatcher> in the web.xml the issue gets resolved.
Now the question arises why?
As per my understanding when we add any action as the value of value attribute of the <put-attribute/> tag the request is forwarded to the mentioned action so the action is executed successfully.
Previously <dispatcher>FORWARD</dispatcher> tag was missing so this issue was caused.
I would really appreciate if any correction is there in my understanding.
Thanks. Happy Coding :).
I don't think you can. You'll need to create a jsp and use the struts2 action tag in it. That can call an action and render part of it's page. If you make a jsp only using the action tag, you'll probably get the effect you want. Have never tried this, but you can probably insert the name of the action and namespace from tiles into the action tag before the jsp is invoked.
I would be very interested to hear how this works out for you.

Resources