|
How does client side validation work with the Struts Validator?
A hint (not yet tested): In your XLS Stylesheet use the document() method to get access to the
validator-rules.xml. Then choose all javascript tags and copy them in your XLS stylesheet.
On the field you like to validate choose the right Javascript function.
Try it out and give us feedback if it works.
How does Error Handling work in StrutsCX?
Read this chapter here.
How does StrutsCX handle i18n?
Read this chapter here.
How can I send the XML-Output-Document directly to the browser?
Add debugxml=true to the Http request. With a session id this may look like this
http://localhost:8080/strutscx/info.do;
jsessionid=8E7?debugxml=true
How can I create PDF output?
First provide a XSL/XSL-FO Stylesheet with XSL-FO elements. Then handle this stylesheet like all the
others in StrutsCX. Add the following command to the Http request:
fop=true or foppdf=true
Note: FOP should be switched ON inside the strutscx-config.xml.
How can I create SVG output?
First provide a XSL/XSL-FO Stylesheet with appropriate SVG elements.
Then handle this stylesheet like all the
others in StrutsCX. Add the following command to the Http request:
fopsvg=true
Note: FOP should be switched ON inside the strutscx-config.xml.
How can I create Print output?
This feature is not yet implemented.
How can I create ASCII output?
First provide a XSL/XSL-FO Stylesheet with appropriate elements.
Then handle this stylesheet like all the
others in StrutsCX. Add the following command to the Http request:
foptxt=true
Note: FOP should be switched ON inside the strutscx-config.xml.
How can I transform my XSL on the client side?
Add the following command to the Http request:
xsl_clientside=true
Note: FOP should be switched ON inside the strutscx-config.xml.
How can I include the Validator?
The Validator in StrutsCX works pretty much the same like the Validator in Struts. First, make
sure you register the validation.xml and the validator-rules.xml through the plug-in
element in your struts-config.xml. Second, edit the validation.xml according your validation
needs of your forms. Third, in your ActionForms get rid of the validate() method. Fourth,
make sure your ActionForm extends the StrutsCXValidatorForm, StrutsCXValidatorActionForm or their
DynaBean counterparts from the com.cappuccinonet.strutscx.validator package. Fifth, invoce
the validate() method of the ActionForm through your Action. Check out the
InfoUpdateAction of the strutscx-demo sample application to see how this may work.
Then, Struts will automatically invoce the Validator on your
ActionForm using the validation constraints your defined in the validation.xml.
Is it necessary to invoke direct the validate() method of the ActionForm in my Action class?
Before StrutsCX v0.9.4 it was necessary to call the validate() method
from within your Action. This has changed now and its possible to
let Struts invoce the validate() method automatically.
For this just configure the action element
the struts-config.xml like this:
<action path="/infoupdate"
type="com....InfoUpdateAction"
scope="request"
name="infoForm"
validate="true"
input="/infoedit.do">
<forward name="success"
path="/infosingle.do"
redirect="false" />
</action>
Here we configure an Action which organizes some data update.
In case input errors occur Struts automatically adds the ActionErrors container to the request
and forwards to the target defined in the input attribute.
This second Action we need to configure here just organizes the presentation
of the data in our form - but no data update:
<action path="/infoedit"
type="com....InfoEditAction"
scope="request"
name="infoForm"
validate="false">
<forward name="success"
path="/StrutsCXServlet"
redirect="false" />
</action>
Note that the /infoedit validate attribute is set to false.
How can I find the properties.xml?
Since StrutsCX v0.9 the properties.xml got renamed to strutscx-config.xml.
Is there a tool to help me generate JavaBeans out of my XSL/HTML forms?
Yes. Check out this Java tip on JavaWorld:
'Automatically generate JavaBeans from XSL files' by Klaus Berg.
How can I separate layout from style in my XSL?
The mix of XLS and HTML elements in you stylesheets can get quite unconvenient.
Check out the Stylesheets of the StrutsCX sample application. There, a big part of the HTML
which forms the basic layout of the site stays in separate files/templates.
In the XSL Stylesheet one of the first things you do, is to include this template.
Bonus: You can include different layouts for different languages. Try it out.
How can I use Tiles in StrutsCX?
The Tiles frameworks features enable layout management in Struts and JSP, which originally
does not exist in these technologies. StrutsCX uses XSLT which enables layout management
right out of the box. Therefore Tiles do not have to be supported in StrutsCX.
Check out this as well.
What are strutscx-definitions?
Since StrutsCX v0.9.1 its possible to define the location of your
XLS Stylesheets similar to the Struts Tiles framework. This is done
inside the strutscx-config.xml like this:
<strutscx-definitions>
<definition name="home.html4.intro">
<put>/WEB-INF/xsl/html4/xsl_1.xsl</put>
</definition>
</strutscx-definitions>
Its possible to define as much <definition> tags inside the <strutscx-definitions>
as you want. Each name attribute should be unique. In your Action you point
to the name of this definition. Note: StrutsCX checks if the String
you pass from your action ends with "xsl". If not, it assumes
you do use strutscx-definitions and looks for it as a name attribute in a definition tag.
Do I have to use the strutscx-definitions?
Yes. Note, since v0.9.1 the data out of the strutscx-config.xml is encapsulated in a
Document object and not in an com.oreilly.xmljava2.XMLProperties object. We recommend to use
JXPath to access the parameters of the Document object. Check this out to see how this works.
How can I access the properties of the strutscx-config.xml?
Since StrutsCX v0.9.1 the strutscx-config.xml gets once read as a JDOM Document object
into the ServletContext. You have
permanently access to it in your Actions through the properties field. Outside you can get it through
(Document) config.getServletContext().
getAttribute(StrutsCXConstants.PROPERTIES); .
We suggest to access the
parameters of this object with JXPath. For a single element this works like this:
// 1. get an XPath handle to the
// properties document object
JXPathContext props =
JXPathContext.newContext(properties);
// 2. access the property with XPath
String xslFile = (String)
props.getValue("//section/info/xsl");
For multiple properties you can use an Iterator instead
Iterator iter =
props.iterator("//section/info/xsl/*");
while (iter.hasNext()) {
String xslFile = (String) iter.next();
logger.info(xslFile);
}
How can I send my data through multiple transformations?
Define a strutscx-definitions element inside the strutscx-config.
Add more than one XSL Stylesheets by supplying more <put> elements, like this:
<strutscx-definitions>
<definition name="home.html4.intro">
<put>/WEB-INF/xsl/html4/xsl_1.xsl</put>
<put>/WEB-INF/xsl/html4/xsl_2.xsl</put>
</definition>
</strutscx-definitions>
The result of the first acts as input document for the next. You can add as much <put> elements
as you need. At the end a classic transformation is done with the result of the 2nd last transformation
as XML input and the XSL Stylesheet assigned in the last <put> element.
Do I have to use Castor XML as data storage?
No. Like in Struts, StrutsCX is completily free from the persistence mechanism you do use. Just the
sample applications use Castor XML. Actually the whole project once startet with Castor XML -
therefore the C in StrutsCX. Anyways we suggest to follow the Data Access Object design pattern
presented in the sample applications for encapsulating all the data access logic.
Is there a way to cache my transformed XML data?
Yes. Take a look at the neteye actioncache.
With the neteye actioncache your actions (and views) that display the content are only invoked when the
underlying data has changed. All you have to do is to write a little bit of code that tells the
controller when the data was last modified. You can dramatically boost the performance of your website
because time expensive operations like data retrieval, JSP processing or XSLT transformations are only
performed once.
My business layer passes back an XML Document. Would I need to
convert this in the business layer to a XML Document object prior to forwarding to StrutsCXServlet?
Up to v0.9.1 the StrutsCXDocumentBuilder consumes an ArrayList with DataBeans and
automatically generates an XML Document for you. - From v0.9.2 StrutsCX the StrutsCXDocumentBuilder
contains some logic to consume a DOM Document, an JDOM Document or an dom4j Document object, too. In either case it
converts the input into a JDOM Element which in a second step gets transformed according your XSL stylesheet.
How can I use the latest StrutsCX version with JDK 1.3?
Some of the jars StrutsCX relies on needs JDK 1.4.
Therefore JDK 1.3 is no longer supported. Anyways, if you need to use JDK 1.3
make sure you do have installed the Java XML Pack. You can download it
from the JavaSoft Website, too. - The necessary
classes are allready included in the JDK 1.4..
In addition use the sources and replace JXPath to access the
StrutsCX properties Document. This should be done at least for the
com.cappuccinonet.strutscx.xslt package.
In addition I got this note from Ed Trembicki-Guy:
"Lastly, I initially had some problems with the SilverStream environment, because it
is using jdk 1.3. I found that the only dependency in the StrutsCX code on jdk 1.4
was a single-argument Locale constructor in
StrutsCXBaseActionHelper.loadResourcePropertiesFiles. Interestingly, nothing else
referenced it, so I removed it and was then able to run in the SilverStream
environment."
And get rid of the StrutsCXEncodingFilter. It was implemented for experimental reasons
but is not used anyways.
In addition read this and this.
My form does contain fields that definitely contains errors. Using
'debugxml=true' parameter, why are there no errors under the 'errors' tag?
This is because you type the 'debugxml=true' just in the location field of your browser, aren't you?
For testing forms add this parameter to the action of your form. Just then the server has access
to all the necessaray parameters in hidden fields and form fields.
Which XML Document type may I pass to the StrutsCXServlet?
Internally the StrutsCXStandardDocumentBuilder and StrutsCXStandardTransformer use JDOM. You can pass them
org.w3c.dom.Documents, org.jdom.Documents and org.dom4j.Documents as well as ArrayList filled with JavaBeans.
You can replace the supplied StrutsCXDocumentBuilder or StrutsCXTransformer with your own version.
I do use dom4j. How do I convert from JDOM to dom4j?
Given a org.jdom.Document you can first convert it to an org.w3c.dom.Document and than to an org.dom4j.Document:
DOMOutputter converter = new DOMOutputter();
org.w3c.dom.Document domDocument
= converter.output(jdomDocument);
org.dom4j.io.DOMReader reader
= new org.dom4j.io.DOMReader();
org.dom4j.Document doc2
= reader.read( domDocument );
On which additional JAR files does StrutsCX rely on?
Check the the installation
page.
How can I use the latest StrutsCX version with Webshere Studio Application Developer 5?
Check out this E-mail a user sent in after releasing StrutsCX v0.9.3
Is there a way to use more than just one ActionForm per Action;
lots of pages uses different Forms, hence ActionsForms, and it would be nice
not to be forced to create one central ActionFrom per page?
This question leads directly to some software architectural concepts. First of all read about
coarse-grained actions forms.
Then rethink your Actions. Rethink your ActionForms. Rethink them as reusable components, not directly
coupled with the HTML page you momentarily have in mind. Maybe you'll pretty fast notice that it's kind of uncool
to have one Super-Action to handle all your ActionForms.
I need a list of all StrutsCX keys. Where is it?
Here it is, the StrutsCX parameter overview.
I do use forms with an encoding different to ISO-8859-1. Where can I learn more on this?
Check out the strutscx-demo.war application. It contains a sample for handling forms in English, German and Korean. Take
a look at the InfoFormReader class to learn how to handle the encoding on incoming Requests.
I need to force the users to follow a specific screen workflow. What can I do?
Check out the
Struts Workflow Extension.
Not yet tested with StrutsCX. Let us know, if you found a way to use it together with StrutsCX.
There's a memory leak while using StrutsCX. What can I do?
This is what a StrutsCX user wrote: "We found the problem about a week back and thought I should update you on it.
There was a memory leak issue with Xalan version 2.5.0 (refer to the
bug report).
After we upgraded to Xalan 2.6.0 the problem was solved."
In one project I had memory problems under Tomcat, but solved them by setting up the heap size of the JVM.
Default is 64MB. Run your Java VM with the following parameters, i.e.:
-Xms256m -Xmx256m //use 256 MB instead of the default
-Xms2g -Xmx2g //se 2 GB instead of the default
Make sure your hardware provides this memory, too.
I like to use StrutsCX v0.9.5 with Java 1.5 but it does throw an error?
Java 1.5 does not contain any longer the xercesImpl.jar by default. Make sure to include it
into your classpath and StrutsCX v0.9.5 should run with Java 1.5 (Thanks to Claudia Nölker for
this hint).
Foreign chars (eg russian) are not displaying correctly after being serialized?
First of all give your browser a hint by adding the character set to the page's meta information, i.e.
<?xml version="1.0" encoding="UTF-8"?>
Second, - for StrutsCX 0.9.5 and older - make sure your ActionForm reset() and validate() methods contain this code snippet at their beginning:
try {
request.setCharacterEncoding("UTF-8");
}
catch (UnsupportedEncodingException ex) {
}
This is what a user wrote:
"The encoding code snippet needs to be placed in the base actionform implementing
the reset() and validate() methods. I added (hardcoded to UTF-8 for now) the piece
of code in the StrutsCxValidatorActionForm validate() method for now and also to
the reset method in my base actionform, and it works nicely. I could actually
move the code snippet into my base actionform's validate and reset methods, that
should also work. I will experiment with moving it around into my other actionforms
to see what happens, so we don't end up coupling a struts fix into cx. Its not CX's
job to solve struts issue? Open to ideas... but so far i think the code snippet
belongs in the base actionform of my project code, not touching cx code at all."
(Thanks to Dudley Butt for this hint).
Up
|