struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wkbutler <kent.but...@gmail.com>
Subject RE: For s:textfield tag how to get value for title attribute from resource bundle.
Date Fri, 10 Jul 2009 17:59:27 GMT

Is this still the only way to get i18n translatations into a struts tag from
the resource bundle?

I'm trying to get a label on some struts fields, i.e.

                <s:textfield 
                   
name="userResponses[%{#loop.index}].userResponseValues[0].value" 
                    label="%{getText('q.client.name.first')}" 
                    value="%{userResponseValues[0].value}" 
                    required="%{formQuestion.required}" 
                    maxlength="%{formQuestion.maxLength}" 
                    cssStyle="width:%{fieldSize}px" 
                    cssClass="text medium"/>

with a messageSource defined as

	<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
	    <property name="basenames"> 
	       <list>
	           <value>classpath:/form</value>
           </list>
        </property>
	    <property name="cacheSeconds" value="7200"/>
	</bean>

I've never seen the getText() work successfully, but the following do work:

<fmt:setBundle basename="form"/>
<fmt:message key="q.client.name.first" />

<i18n:bundle baseName="form" id="b1">
    <i18n:message key="q.client.name.first" bundle="${b1}" />
</i18n:bundle>

I also have the JSTL message source defined in web.xml still, but removing
that doesn't help the getText succeed.

Any ideas on getting getText() to work?  Or alternatives ways of getting an
i18n label on the s:textfield?  Thanks for any ideas -




LEONARD Julien (Consulting for ACCOR Hotels) wrote:
> 
> Try this :
> 
> <s:textfield theme="xhtml" label="" key="categoryName"
> cssClass="fieldGreen validate-alpha " value=""
> title="%{getText('category.categoryName')}" id="categoryName"/> 
> 
> http://struts.apache.org/2.0.11/docs/localization.html
> 
> Julien
> 
> -----Message d'origine-----
> De : VJ22 [mailto:Vijay.Nair@iflexsolutions.com] 
> Envoyé : vendredi 22 février 2008 16:26
> À : user@struts.apache.org
> Objet : For s:textfield tag how to get value for title attribute from
> resource bundle.
> 
> 
> For s:textfield tag how to get value for title attribute from resource
> bundle. 
> I tried using <fmt:message> but seems the struts2 is  not recognising this
> inside the title tag and considering it as plain text.
> Please let me know if there exists a way to do the same For eg i tried 
> <td width="80%"<s:textfield theme="xhtml" label="" key="categoryName"
> cssClass="fieldGreen validate-alpha " value="" title="<fmt:message
> key='category.categoryName'/>" id="categoryName"/>
> 
> Here category.categoryName is refering to resouce bundle property.
> 
> --
> View this message in context:
> http://www.nabble.com/For-s%3Atextfield-tag-how-to-get-value-for-title-attribute-from-resource-bundle.-tp15634305p15634305.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> ----------------------------------------------------------------------------------------
> 
> 

-- 
View this message in context: http://www.nabble.com/For-s%3Atextfield-tag-how-to-get-value-for-title-attribute-from-resource-bundle.-tp15634305p24432096.html
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


Mime
View raw message