Format values in MessageResources

2007-07-03 Thread Ramon Xuriguera i Albareda

Hi,
I've just noticed that it's possible to format args in a
MessageResources' key (see
http://www.jguru.com/faq/view.jsp?EID=915891). I'm trying to do the
following:

In MessageResources.properties
label.mean=Nota mitjana: {0,number}

Then, in my JSP:
bean:message key=label.mean arg0=${mybean.mean}/

I get this error:
14:52:58,546-ERROR
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC].[jsp]
-Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: unknown format type at
at java.text.MessageFormat.makeFormat(Unknown Source)
at java.text.MessageFormat.applyPattern(Unknown Source)
at java.text.MessageFormat.init(Unknown Source)
at 
org.apache.struts.util.MessageResources.getMessage(MessageResources.java:302)


Do I have to define these formats somewhere?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validator does not validate!

2007-07-03 Thread Ramon Xuriguera i Albareda

I don't know exactly what the problem was. After spending lots of
hours in front of the computer it worked!

I think the problem had something to do with what you say or, probably
with the exception I define in the action mapping.

Anyway, thanks.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validator does not validate!

2007-06-30 Thread Ramon Xuriguera i Albareda

Thanks but, it doesn't work either...
Any other ideas?

2007/6/30, Dave Newton [EMAIL PROTECTED]:


Subclassing ValidationActionForm means that the form
name attribute in validation.xml would be the action
path, not the bean name. You want ValidationForm if
you want the validation form name to be the bean name.

...


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Validator does not validate!

2007-06-29 Thread Ramon Xuriguera i Albareda

I have some problems validating a form with validator framework under
struts 1.3.
After submitting, it forwards to success page even if the fields
were not filled properly.
(No exceptions are thrown).

Here's some of my code:

STRUTS-CONFIG.XML
form-beans
...
form-bean
name=subjectForm
type=tfc.controller.formbeans.SubjectForm / 
...
/form-beans

action-mappings

   action
   path=/SubjectInfoAction
type=tfc.controller.actions.SubjectInfoAction
name=subjectForm
scope=request
validate=true
input=/pages/kindex.jsp

exception
key=errors.notFound
path=Exception
type=tfc.controller.exceptions.NotFoundException/

forward name=success path=/topics.jsp/
forward name=studentSuccess path=/studentTopics.jsp/
/action

/action-mappings

VALIDATION.XML
formset
form name=subjectForm
field
property=subjectId
depends=required
arg key=parameters.subjectId/
/field

field
property=studentId
depends=integer
arg key=parameters.studentId/
/field
/form
/formset

FORM (kindex.jsp)
jsp:root
xmlns:jsp=http://java.sun.com/JSP/Page;
xmlns:html=http://struts.apache.org/tags-html;
xmlns:logic=http://struts.apache.org/tags-logic;
xmlns:bean=http://struts.apache.org/tags-bean;
version=1.2

jsp:directive.page contentType=text/html/

jsp:text
html:html
body

html:errors /

html:form action=SubjectInfoAction
html:text  styleId=studentId 
property=studentId/
html:text  styleId=subjectId 
property=subjectId/
html:submit property=submit value=submit/
/html:form

/body
/html:html
/jsp:text

/jsp:root

FORMBEAN (SubjectForm.java)
It extends ValidationActionForm and it has the getters and setters for
the attributes and some other methods.
It does not impelement reset() nor validate()

ACTION (SubjectInfoAction.java)
It just returns success forward.

PART OF THE LOG
As you can see, it does load 'validation.xml' and 'validation-rules.xml'.
03:03:15,281-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-No Configuration for this context.  Initializing.
03:03:15,281-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-configuring cewolf app..
03:03:15,296-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-using storage class de.laures.cewolf.storage.TransientSessionStorage
03:03:15,296-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-using overlibURL etc/overlibCewolf.js
03:03:15,296-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-debugging is turned off
03:03:15,296-INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/TFC]
-...done.
03:03:16,015-INFO org.apache.struts.action.ActionServlet -Loading
chain catalog from
jar:file:/C:/Tomcat5.5/webapps/TFC/WEB-INF/lib/struts-core-1.3.5.jar!/org/apache/struts/chain/chain-config.xml
03:03:17,968-INFO org.apache.struts.validator.ValidatorPlugIn -Loading
validation rules file from '/WEB-INF/validation.xml'
03:03:18,000-INFO org.apache.struts.validator.ValidatorPlugIn -Loading
validation rules file from
'/org/apache/struts/validator/validator-rules.xml'
03:03:19,140-INFO org.apache.struts.tiles.TilesPlugin -Tiles
definition factory loaded for module ''.
...

RESULT
So, as I said before, the application does not crash, but it redirects
to success page even if some
fields' values are not correct.
For example:
In this case, although 'subjectId' is required, you can leave it empty.


Thanks,
Ramon

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]