You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pedro Solorzano <pe...@sun.com> on 2007/06/18 22:05:51 UTC

Freemarker Error! on validator i18n message

I have a webwork validation depending on a key for i18n. The first time it
shows the form it also shows a:

FreeMarker template error!

Method public java.lang.String
com.opensymphony.xwork2.validator.validators.ValidatorSupport.getMessage(java.lang.Object)
threw an exception when invoked on
com.opensymphony.xwork2.validator.validators.RequiredStringValidator@185ccd9
The problematic instruction:

----------
==> ${validator.getMessage(action)?js_string} [on line 28, column 26 in
template/xhtml/form-close-validate.ftl]
 in include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" [on
line 3, column 1 in template/xhtml/form-close.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String
com.opensymphony.xwork2.validator.validators.ValidatorSupport.getMessage(java.lang.Object)
threw an exception when invoked on
com.opensymphony.xwork2.validator.validators.RequiredStringValidator@185ccd9
	at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)

...

Caused by: java.lang.NullPointerException
	at
com.opensymphony.xwork2.validator.DelegatingValidatorContext$LoggingValidationAware.<init>(DelegatingValidatorContext.java:234)
	
---------------------------------------------

Looks like the framework doesn't find the .properties key. But if I force
the error (do not complete the field) the form appears with no FreeMarker
error and with the defined value for the key correctly shown besides the
field. If I go back to the index, it will show the error again.

Obviously if I place a plain message instead a properties key it works fine.

Any Clue?



HelloAction-validation.xml:

<validators> 
    <field name="name">
        <field-validator type="requiredstring"> 
            <message key="error.campo.requerido"/>

<!--<message> This will work Fine!
                Campo Requerido
            </message>-->

        </field-validator> 
    </field>
</validators>


mensajes.properties:
error.campo.requerido=Campo Requerido i18n


struts.xml:

        <action name="HolaMundo"
class="org.test.presentation.web.hello.HelloAction">
            <result name="input">/index.jsp</result>
            <result>/result.jsp</result>
        </action>

index.jsp:

        <h1><s:text name="titulo.hola"/></h1>
        
        <s:form action="HolaMundo" method="POST" validate="true">
            <s:textfield label="%{getText('campo.nombre.peticion')}"
name="name"/>
            <br><s:submit value="%{getText('boton.hola.peticion')}"/>
        </s:form>

Everything loading from .properties as expected.
-- 
View this message in context: http://www.nabble.com/Freemarker-Error%21-on-validator-i18n-message-tf3942521.html#a11183076
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org