Untested, and I didn't check the docs... but your expression in attribute "key" of the following would require double evaluation. This is because an attribute is a simple String or an OGNL expression. Your value in key requires that concatenation occur after evaluation...
<s:label key="form.label.%{name}" cssClass="ym-required" /> In stead an expression of the form: "%{"form.label." + name}", would be better. Although there is still the issue of _name_ being in scope, maybe you will need an " #attr." prefix... On Sat, Oct 19, 2013 at 6:09 PM, Martin Gainty <mgai...@hotmail.com> wrote: > //only if component-name and its URL is placed into a HashMap and that > HashMap is set into the bean > > //here is the chronology: > > > //straightforward HashMap which contains component name and the component > > private java.util.Map<String, Object> dynamicAttrs = new > java.util.HashMap<String, Object>(); > > > > //In this case we are setting data-remote and data-label components into > dynamicAttrs HashMap > > dynamicAttrs.put("data-remote", "data-remote_"); > dynamicAttrs.put("data-label", "data-label_"); > > > //to tell the bean which Attributes will be set dynamically > > org.apache.struts2.components.UIBean bean; > > bean.setDynamicAttributes(dynamicAttrs); > > > > //the dynamicAttributes functionality is in struts2-javatemplates-plugin so > > //when you building struts make sure you add struts2-javatemplates-plugin > dependency as seen here > > <dependency> > <groupId>org.apache.struts</groupId> > <artifactId>struts2-javatemplates-plugin</artifactId> > <version>${project.version}</version> > </dependency> > > > did you set your component-name and URL into dynamicAttrs > setDynamicAttributes of the bean you wish to access? > > > > HTH, > Martin > ______________________________________________ > Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le > destinataire prévu, nous te demandons avec bonté que pour satisfaire > informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie > de ceci est interdite. Ce message sert à l'information seulement et n'aura > pas n'importe quel effet légalement obligatoire. Étant donné que les email > peuvent facilement être sujets à la manipulation, nous ne pouvons accepter > aucune responsabilité pour le contenu fourni. > > > > > > Date: Sat, 19 Oct 2013 05:15:16 -0700 > > From: afatt...@yahoo.com > > Subject: Re: Passing jsp tag attribute to Struts 2 tags > > To: user@struts.apache.org > > > > Actually I am not calling any action class getKeyLable > > > > I try to: > > 1- Make the s:label tag get a dynamic (Is it poosibel ?!) > > 2- The above dynamic value must be read from jsp tag ( The s:label is > used in a tag itself) > > > > ~Regards, > > ~~Alireza Fattahi > > > > > > > > On Saturday, 19 October 2013, 15:35, Martin Gainty <mgai...@hotmail.com> > wrote: > > > > * In this example, a label is rendered. The label is retrieved from a > ResourceBundle via the key attribute > > * giving you an output of 'User Name: Ford.Prefect'. Assuming that i18n > message userName corresponds > > * to 'User Name' and the action's getUserName() method returns > 'Ford.Prefect'<p/> > > * <!-- END SNIPPET: exdescription --> > > * <pre> > > * <!-- START SNIPPET: example --> > > * <s:label key="userName" /> > > * <!-- END SNIPPET: example --> > > * </pre> > > * <pre> > > * <!-- START SNIPPET: example2 --> > > * <s:label name="userName" label="User Name" /> > > * <!-- END SNIPPET: example --> > > * </pre> > > > > > > what is returned by your Action Class getLabelKey Method > > > > > > Martin > > ______________________________________________ > > Verzicht und Vertraulichkeitanmung > > > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > > > > > > > > > > > > Date: Sat, 19 Oct 2013 04:23:55 -0700 > > > From: afatt...@yahoo.com > > > Subject: Passing jsp tag attribute to Struts 2 tags > > > To: user@struts.apache.org > > > > > > > > > Hi, > > > > > > I am creating a new tag in jsp, named `RequiredLabel` , but I can not > pass tag attribute to struts label ( The css are based on YAML) > > > > > > The tag will be used as: > > > <myTag:RequiredLabel name="amount"/> > > > > > > The label should be get from struts as it must be localized. > > > <%@tag description="Renders a label with required css and error > label" pageEncoding="UTF-8"%> > > > <%@attribute name="name" required="true" %> > > > <%@taglib prefix="s" uri="/struts-tags"%> > > > > > > <!--Here ${name} works fine --> > > > <p class="ym-message" id="${name}Error" /> > > > <!-- Here I can not pass the name to s:label tag --> > > > <s:label key="form.label.%{name}" cssClass="ym-required" /> > > > > > > I tried `#attr.name` and `#param.name` but none of them worked! > > > Do you know any solution ?! > > > > > > > > > > > > ~Regards, > > > ~~Alireza Fattahi > >