Usage of Tiles 2.2 with Struts 1.x (1.2) compatibility - Reg - struts-1

We have started migrating our project (Web Application) which is running on Struts 1.x (1.2) from Framesets to Tiles 2.2.
As stated in the Apache tiles tutorial we have made few modifications in web.xml and added tiles-defs.xml to the project. But couldn't get the relation towards the struts-config.xml to the tiles-defs.xml.
Is Tiles 2.2 compatible with struts 1.x? Can some one please guide me in proper direction or provide me samples to integrate Tiles 2.2 in our Struts 1.x project?
Any kind of help would be appreciated at the earliest as we need to prepare a demo in a couple of days.
Thanks and Regards,
Purushotham Reddy P

The relation between struts-config and tiles would be the following, if you action class returns "success" struts-config file will forward it to the "tile.AddUpdateTransportation.view" tiles
struts-config.xml File:
<action path="/transportationAddUpdate1"
type="com.struts.action.TransportationAction"
name="Form1"
scope="session" validate="false">
<forward name="success"
path="tile.AddUpdateTransportation.view">
</forward>
</action>
tiles-defs.xml:
<definition name="tile.AddUpdateTransportation.view"
extends=".tops.core.layout">
<put name="content" value="/transportation.jsp" />
<put name="title.section" value="Transportation - Add/Copy/Delete"/>
</definition>

Related

Spring Webflow 2.4.2 missing start state

I just started adding Webflow to a Spring MVC project and I'm getting this compile error on my flow.xml component:
Start state is missing. Add at least one state to the flow
I found an identical post on SO from a year ago: webflow.xsd - Start state is missing. Add at least one state to the flow.
No one responded to this question but I found it in the Jira repository for Spring Webflow: webflow.xsd - Start state is missing. Add at least one state to the flow. It is marked as Cannot Reproduce.
Here is an excerpt from my very simple webflow.xml.
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd">
<on-start>
<evaluate expression="recipeService.createRecipe(currentUser.name)" result="flowScope.recipe" />
</on-start>
<view-state id="basics" view="recipe/basics" model="recipe">
<transition on="proceed" to="ingredients"></transition>
<transition on="cancel" to="cancel"></transition>
</view-state>
... more states ...
<end-state id="end" view="recipe/end"/>
<end-state id="cancel" view="recipe/end"/>
</flow>
The documentation indicates that start-state is optional - the first view-state will be assumed to be the start. If I change the spring-webflow-2.4.xsd to 2.0 the error goes away, but then I get a different error if I attempt to use validation-hints on any of the view-state entries. "Basic1" and "Basic2" in the example below are validation groups on the recipe model.
<view-state id="basics" view="recipe/basics" model="recipe" validation-hints="'basic1,basic2'">
I'm using
STS 3.6.4
Spring 4.1.6.RELEASE
Spring WebFlow 2.4.2.RELEASE
Spring Security 4.0.2.RELEASE
Java 1.7
Hibernate 4.3.10.FINAL
I'm using java-based config for everything, but I don't think that is where the problem lies unless I have a mismatch in the versions that Webflow 2.4.2 requires? I can post my WebMvcConfig and WebFlowConfig or the pom.xml or any other info if that would help.
Any assistance would be greatly appreciated.
EDIT #1: excerpts from java config
From WebFlowConfig.java:
#Bean
public FlowDefinitionRegistry flowRegistry() {
return getFlowDefinitionRegistryBuilder(flowBuilderServices())
.setBasePath("/WEB-INF/views")
.addFlowLocationPattern("/**/*-flow.xml")
.build();
}
From WebMvcConfig.java
#Override
public void addViewControllers(final ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/recipe/basics.htm");
registry.addViewController("/recipe/ingredients.htm");
registry.addViewController("/recipe/instructions.htm");
registry.addViewController("/recipe/optional.htm");
registry.addViewController("/recipe/end.htm");
}
Using 2.0 all of the pages are executed in the correct order.
EDIT #2
I forgot to mention that even with the 2.4 xsd compile error the webflow does get executed, same as in the post from a year ago. I also found this issue regarding STS: webflow config gives incorrect "Start state definition is missing." error. The indicated fix version is 3.3.0.M1 so I would assume (?) the fix is still included in STS 3.6.4.
I spent several hours trying everything I could think of, including replacing nearly everything in the pom.xml with the contents of the pom.xml from the booking-mvc sample project, which was not displaying this error in spite of also being set to version 2.4.2. Since webflow seems to be tied into Thymeleaf and Tiles (which I am not using) I thought there might be a dependency in those projects which would remove the error. There was not.
So I went through the properties of the booking-mvc project and compared them to mine. The only relevant difference I could see was in the Spring | Web Flow Support. My project listed my recipe-flow.xml, but booking-mvc did not display its -flow.xml file. Once I removed my flow.xml file the error disappeared.
I have no idea how the file ended up in this config location and I can't find any documentation on what this property is for, but apparently it's a no-no, at least in my project. It took a while to get my pom.xml back in shape but the app is now working again.
Here are the differences between the 2.0 and 2.4 xsd's
http://diffchecker.com/oqx5rq7t
With the only diffrence being the addition of validation-hints attribute.
Not sure what else can be deduced from that. Maybe this is a bug with eclipse/STS with how it is parsing the xsd files.
As Rossen indicated in the SWF jira ticket every sub element in the xsd is defined with minOccurs="0" https://jira.spring.io/browse/SWF-1646
so I think this isn't a SWF issue but a STS/Eclipse parsing issue.
I have finally found the solution.
Eclipse think "Start state is missing" because he thinks the XML is a "Spring Web Flow Definition File", but he is wrong.
The solution is to tell Eclipse the XML is not a "Spring Web Flow Definition File".
Open "Spring Explorer", you will find the XML shown in "Web Flow", right click and select "Properties", you can see the XML is in "Web Flow Support / Config Files" list. Just remove it.

Alfresco Custom Content Type not showing

I have been trying to follow this tutorial about Alfresco custom content types
http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html#localizing-strings-for-custom-content-models.
However, when I get to the 'Test your changes' step and I go to manage rules, I can't manage to get the custom types created (sc_doc and sc_whitepaper) in the dropdown list.
My share-config-custom.xml:
<!-- Share configuration related to this particular Share module extension, such as:
- Doclib action config
- Form config
- Aspect and Type config
Note. Any configuration related to the whole Share.war webapp
(i.e. not specific to this share extension) should be
placed in the environment specific config:
alfresco/tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml file
-->
<alfresco-config>
<!-- Document Library config section -->
<config evaluator="string-compare" condition="DocumentLibrary">
<aspects>
<!-- Aspects that a user can see -->
<visible>
<aspect name="sc:webable" />
<aspect name="sc:productRelated" />
</visible>
<!-- Aspects that a user can add. Same as "visible" if left empty -->
<addable>
</addable>
<!-- Aspects that a user can remove. Same as "visible" if left empty -->
<removeable>
</removeable>
</aspects>
</config>
<config evaluator="node-type" condition="DocumentLibrary">
<types>
<type name="cm:content">
<subtype name="sc:doc" />
<subtype name="sc:whitepaper" />
</type>
<type name="sc:doc">
<subtype name="sc:whitepaper" />
</type>
</types>
</config>
</alfresco-config>
PS: Do I have to re-run 'mvn install' after every change I make in the .xml using Eclipse?
Any help will be much appreciated!
I know i am posting this answer bit late
and my solution is bit poor, But it works for me :)
I hope it will also work for you.
Strange thing is i am following same tutorial and at the time of 'Test your changes' stage not able to see my custom types on the server.
so to make it working in my share project i have changed place of
share-config-custom.xml
from src/main/resources/META-INF to src/main/amp/config/alfresco/web-extension
and restart alfresco and now able to view my custom types in type list on server.
plz post your answer if you have make done this by any other way :)
thank you.
I am not sure which kind of project you have created from maven artifacts.
Repository AMP archetype
All-In-One (AIO) archetype
Share AMP archetype
Here you can see list of all maven commands.
If you are not using local maven repository then you can go for "mvn package" to generate new AMP files and then deploy them manually on alfresco server.

Simple axis2.xml for Axis2 embedded in webapp

I am developing a webapp with an embedded webservice with Axis2 using Maven.
The service implementation is a POJO with RPC-style interaction, the target appserver is Tomcat running the Axis2 servlet.
The "Hello world" works but now I need to configure some global axis2 settings in the axis2.xml file (placed under WEB-INF/conf).
Please provide or point to a simple configuration for axis2.xml for this common environment.
The default taken from the binary distribution has too many features activated (hotdeploy?) and also causes this problem:
<soapenv:Reason>
<soapenv:Text xml:lang="en-US">
The ServiceClass object does not implement the required method
in the following form: OMElement ping(OMElement e)
</soapenv:Text>
</soapenv:Reason>
As a reference: http://axis.apache.org/axis2/java/core/docs/servlet-transport.html says to configure the servlet transport in this way, but it does not solve the issue.
<transportReceiver name="http" class="org.apache.axis2.transport.http.AxisServletListener"/>
Apparently the problem is that the default axis2.xml sets raw xml messageReceivers, instead of the RPC ones.
Try to add this to the services.xml for the developed service, should fix the problem.
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
"Solution that worked for me was adding the operation tag in the service.xml against the Java Service method name:
<operation name="sayHello" >
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="ServiceClass" locked="false">com.learning.webservices.pojo.HelloService</parameter>

Using Thymeleaf with Tiles2 and Spring

I'm trying to use Thymeleaf integration with Apache Tiles 2.x. They have a guide how to make it work so I followed it, but now I'm stuck.
Basically this integration allows using both JSPs and Thymeleaf templates and according to the guide, you should be able to tell which to use by setting the type attribute in your title-definition files. Default option is Thymeleaf.
Because I am slowly migrating from JSP, the vast majority of the templates are JSPs, so I need to use this type attribute, but then I get an error that my title definition file is not valid:
org.apache.tiles.definition.DefinitionsFactoryException: XML error reading definitions.
at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:332)
at org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO.loadDefinitionsFromURL(BaseLocaleUrlDefinitionDAO.java:276)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(CachingLocaleUrlDefinitionDAO.java:251)
at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(ResolvingLocaleUrlDefinitionDAO.java:65)
at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadParentDefinitions(ResolvingLocaleUrlDefinitionDAO.java:58)
at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(CachingLocaleUrlDefinitionDAO.java:239)
at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(ResolvingLocaleUrlDefinitionDAO.java:65)
...
This is my tiles definition file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="default" template="/WEB-INF/layouts/default.jspx" type="jsp">
</definition>
</tiles-definitions>
If I remove DOCTYPE part, I got same error.
Any idea how to get it working?
The type attribute only exists in <put-attribute/> elements. By contrast, <definition/> elements require your attribute to be called templateType.
Regards.

How to write single component XML to install it on all versions of Joomla?

I've written 4 different component xmls for 4 Joomla versions i.e v1.5, v1.6, v1.7 and v2.5.
All the 4 xmls are exactly same except only one line which specifies joomla version number.
For v1.5 : <install type="component" version="1.5.0">
For v1.6 : <install type="component" version="1.6.0">
For v1.7 : <install type="component" version="1.7.0">
For v2.5 : <install type="component" version="2.5.0">
Is is possible to keep just one XML for all Joomla versions?
please guide..
You should have more differences than that. There have been some changes from 1.5 to 1.6+ that are required.
The good news is that Joomla will ignore anything in an install package that it does not recognize so you can safely put everything for multiple versions in one package. Also lucky for you, the Joomla documentation is pretty good for this exact subject.
XML configuration file instructions - http://docs.joomla.org/Making_single_installation_packages_for_Joomla!_1.5,_1.6_and_1.7#One_XML_configuration_file.2C_multiple_Joomla.21_versions
Single install package for multiple versions - http://docs.joomla.org/Making_single_installation_packages_for_Joomla!_1.5,_1.6_and_1.7
Here is the code from JCE for joomla 2.5:
<install type="component" version="1.5.0" method="upgrade">
So I guess if you simply do the same it will run on higher versions.
Just remember that the parameters has changed between J1.5 - J 1.6. You can specify them in the same XML-file though:
example:
<!-- Standard plugin parameters for Joomla! 1.5 -->
<params>
<param name="paramname" type="text" default="" label="" description=""/>
</params>
<!-- Standard plugin parameters for Joomla! 1.6+ -->
<config>
<fields>
<field name="paramname" type="text" default="" label="" description=""/>
</fields>
</config>

Resources