Struts 2 Documentation > The Vault |

Struts 2 Documentation
The Vault
Edit Page Browse Space Add Page Add News
Added by phil, last edited by Ted Husted on Sep 12, 2006 (view change)

| About the Vault The Vault contains lots of unsorted problems, snippets, remarks and ideas, mostly found in posts in the WebWork Forum. You can think of this page as a place to store content before it is analyzed and put in the FAQ, Cookbook, Examples, or Reference. Material in the Vault is raw, unpolished, and can contain typos. If you can't find it elsewhere, be sure to rummage through the Vault and search the forum. Feel free to redraft material from this page and move it to a better location. (That's why it's here!)

## Migration to 2.2

### Note about upgrading your WW tags to 2.2

- http://forums.opensymphony.com/thread.jspa?threadID=13870&tstart=0

Just a quick fyi that caused issues for us... In 2.2 when extending UIBean evaluateExtraParams() no longer takes parameters. (Our parameters were not working until we realized that evaluateExtraParams was not being invoked due to the change.) In 2.1 evaluateExtraParams was passed the stack IIRC.

Not sure if this is documented anywhere but it caused us quite a headache when migrating from 2.1 to 2.2.

### Where did the velocity templates go ?

- http://forums.opensymphony.com/thread.jspa?threadID=13108&tstart=0

checking cvs log, it seems that Pat has removed it with comment as follows:

removing velocity macro implementations - they are so old and out of date now it will cause more harm than good keeping them around

## Best practices

### Should I make an action or rather link to a .jsp page ?

- http://forums.opensymphony.com/thread.jspa?threadID=14424&tstart=0

If you put an action configuration in your xwork.xml but don't put an action class attribute, it will default to using the ActionSupport class, which just returns SUCCESS.

## Type conversion

### Type conversion for a static inner class ?

- http://forums.opensymphony.com/thread.jspa?threadID=15060&tstart=0

Collection_inner property name = your.package.ClassName$StaticInnerClassName (notice the dollar sign between the fully qualified Class name and the static inner class)

## Migration to Spring IoC

### How can we migrate ServletRequestAware, ServletResponseAware and ValidationAware to Spring bean definitions?

- http://forums.opensymphony.com/thread.jspa?threadID=13551&tstart=0

I tink just the normal way would work. The action will now be created by spring, and if the ServletConfigInterceptor is in the stack and the action implementation implement those interface, webwork should set the appropriate methods.

## Freemarker, Velocity, JSP

### How to disable Velocity template caching

- http://forums.opensymphony.com/thread.jspa?threadID=15405&tstart=0

The "wwclass" was the resource loader I need to change.
Here's the lines from Velocity.props:

    wwfile.resource.loader.cache=false
    wwclass.resource.loader.cache=false

(http://jroller.com/page/gigix?entry=velocity_performance_issue_solved)

### How to catch Freemarker exceptions (the ugly big yellow pages)

- http://forums.opensymphony.com/thread.jspa?threadID=13829&tstart=0

FreeMarker delegates exception handling to so-called TemplateExceptionHandlers. By default the HTML_DEBUG_HANDLER is used (this one generates the yellow error page), but you can easily specify a different exception handler by using the setTemplateExceptionHandler method of your configuration object. FM provides some simple handlers you can use, in your case I recommend the RETHROW_HANDLER (
http://freemarker.org/docs/api/freemarker/template/TemplateExceptionHandler.html).

### My ww:include actions aren't processed

- http://forums.opensymphony.com/thread.jspa?threadID=13479&tstart=0

Did you declare the ww tag library in your includes ? If I'm not mistaken, jsp includes work different from ww includes (ww process the pages before including them).

### I'm using ww:urlHelper in combination with the c:out tag, but it won't work !

- http://forums.opensymphony.com/thread.jspa?threadID=14312&tstart=0

if the url with &amp is used in the value attribute it will not work properly unless the escapeXml is set to false.

## Validation

### How to disable validation on the first page load (to show a in input form)?

- http://forums.opensymphony.com/thread.jspa?threadID=14634&tstart=0

If you define your own stack you can exclude methods from validation by adding the excludeMethods param to both Validation and Workflow. Assuming you are using the defaultStack the the methods input, back and cancel will be ignored. Change default to action!input and declare the input method to return INPUT.

### When using clientside validation, DWR states it gets No Data From Server

- http://forums.opensymphony.com/thread.jspa?threadID=14135&tstart=0

When using firefox if a user has focus on an input control and then clicks the submit button i get a DWR error stating that there was no data from the server.
I searched around on this group and did not see a solution. Via the DWR mailing list I found a post fromi Joe Walker stating that a workaround was to register a custom DWR error handler ..
http://getahead.ltd.uk/dwr/browser/engine/errors

### Why can't I use && (=and) in my validation rules ? || (=or) does work !

- http://forums.opensymphony.com/thread.jspa?threadID=15576&tstart=0

You can't use && directly since the validation files have to be wellformed xml. The correct syntax would be &amp ;&amp ; (without the spaces)

## Ajax, Javascript

### Datepicker i18n problems

- http://forums.opensymphony.com/thread.jspa?threadID=14132&tstart=0

DatePicker might have some problems in certain localised enviroments, because some of the language files included in DHTML / JavaScript Calendar are not valid (don't have some variables, for example WEEKEND definition).

Is simple solution to overide files like:
http://localhost:8080/showcase/webwork/jscalendar/lang/calendar-(your language).js

The only way to fix that, is correct calendar-(your language).js...

Already fixed for 2.2.1, available via CVS HEAD:

- sv
- pl
- cn

### Datepicker does not allow time editing, or works with wrong date format

- http://forums.opensymphony.com/thread.jspa?messageID=48644&#48644

The trick is to format the date correctly before sending it to the datepicker, AND telling the datepicker what format you are using.

    <ww:date name="%{new java.util.Date()}" format="dd-MM-yyyy hh:mm" id="date"/>
    <ww:datepicker value="%{#date}" showstime="%{true}" format="%d-%m-%Y %H:%M"/>

Note: of course you should use property keys here, but you'll have to specify different keys, since the formatting expression for java and javascript are different (but should result in the same format !):

    my.java.datetime.format=dd-MM-yyyy hh:mm
    my.javascript.datetime.format=%d-%m-%Y %H:%M

And the use the following snippet instead:

    <ww:date name="%{new java.util.Date()}" format="%{getText('my.java.datetime.format')}" id="date"/>
    <ww:datepicker value="%{#date}" showstime="%{true}" format="%{getText('my.javascript.datetime.format')}"/>

## Application servers

### WebWork hot-redeployment problem with Tomcat 5.5

- http://forums.opensymphony.com/thread.jspa?threadID=14553&tstart=0

Try to adjust your Tomcat context settings...

    <Context docBase="${catalina.home}/webapps/YOURWEBAPP"
             antiResourceLocking="true" antiJARLocking="true">
    ...
    </Context>

### Deploying WebWork on Glassfish

- http://forums.opensymphony.com/thread.jspa?threadID=17532&messageID=34365#34365

One of my co-workers was deploying a forum application that uses WebWork code. He ran into some deployment and execution issues, related to the sercurity policy. If you want to deploy WebWork apps on GlassFish, you may want to read http://blogs.sun.com/roller/page/paulsen?entry=configuring_the_security_manager_in

## Browser

### Different version of a browser co-existing together

- http://blog.dojotoolkit.org/2005/12/01/running-multiple-versions-of-firefox-side-by-side
- http://labs.insert-title.com/labs/Multiple-IEs-in-Windows_article795.aspx
- http://www.skyzyx.com/archives/000094.php