You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Louis Voo <jl...@yahoo.com> on 2009/12/02 19:14:50 UTC

How to get the key name

Hi,

I've this text field in my jsp

<s:textfield key="label.name" name="user.name" maxlength="35" required="true"/>

and this property in the resource bundle

error.required = ${getText(fieldName)} is required.
label.name = Name


When there is validation error, it looking for user.name property, it is fine because I'm using fieldName, so my question is there anyway I can get key name? So that I can use the label.name property.


Regards
LV

Re: How to get the key name

Posted by Saeed Iqbal <sa...@gmail.com>.
I am sorry i dont think i can be of any more help

On Thursday, December 3, 2009,  <ma...@yahoo.com> wrote:
> Ok, now I know what you mean the key, you mean ${getText(label.name)} ?
> But that is not that I want, if I hard code the key name there, that defeat the whole reuse purpose.
> I want something similar like fieldName but for key. fieldName is a constant variable from struts, when I write the code like this
> error.required = ${getText(fieldName)} is required.
>
> and if I have these 2 tag in jsp:
> <s:textfield key="label.name" name="user.name" maxlength="35" required="true"/>
> <s:textfield key="label.email" name="user.email" maxlength="35" required="true"/>
>
> In runtime when validation error, it will search for user.name and user.email property in the resource bundle files.
>
> So, if I've this
> user.name = Name
> user.email = Email
> in the resource bundle files,
>
> Then it will display correctly as
> Name is required.
> Email is required.
>
> But in my resource bundle files, I only have
> label.name = Name
> label.email = Email
>
> Which map to the key, so I need to find a way to get it.
>
> Hope you can understand, sorry for my poor description.
>
> Regards
> LV
>
>
>
>
> ________________________________
> From: Saeed Iqbal <sa...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, December 3, 2009 12:29:30 PM
> Subject: Re: How to get the key name
>
> No not that
>
> key="i8nl.nameKey"
>
> Send me your file
>
> On Thu, Dec 3, 2009 at 5:27 PM, <ma...@yahoo.com> wrote:
>
>> No, I changed my property to this
>> error.required = ${getText(key)} is required.
>>
>> It is not working.
>>
>>
>>
>> ________________________________
>> From: Saeed Iqbal <sa...@gmail.com>
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Sent: Thu, December 3, 2009 9:56:29 AM
>> Subject: Re: How to get the key name
>>
>> Yes key is in struts. See the docs.
>>
>> On Thu, Dec 3, 2009 at 2:54 PM, <ma...@yahoo.com> wrote:
>>
>> > Hi,
>> >
>> > Sorry, I think you misunderstanding my question.
>> >
>> > My main question is fieldName give me the name attribute value, but I
>> want
>> > to get my key attribute value, is there anything like fieldKey or
>> something
>> > ?
>> >
>> > <s:textfield key="label.name" name="user.name" maxlength="35"
>> > required="true"/>
>> >
>> > fieldName = user.name
>> >  ?? = label.name
>> >
>> > Thanks
>> > LV
>> >
>> >
>> >
>> > ________________________________
>> > From: Saeed Iqbal <sa...@gmail.com>
>> > To: Struts Users Mailing List <us...@struts.apache.org>
>> > Sent: Thu, December 3, 2009 2:13:20 AM
>> > Subject: Re: How to get the key name
>> >
>> > You use the key attribute instead of label
>> >
>> > On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
>> > >
>> > > Try this,
>> > >
>> > > <s:text name="label.name" />
>> > > <s:textfield name="user.name" maxlength="35" required="true"/>
>> > >
>> > > -siddiq.
>> > >
>> > >
>> > > Louis Voo wrote:
>> > >>
>> > >> Hi,
>> > >>
>> > >> I've this text field in my jsp
>> > >>
>> > >> <s:textfield key="label.name" name="user.name" maxlength="35"
>> > >> required="true"/>
>> > >>
>> > >> and this property in the resource bundle
>> > >>
>> > >> error.required = ${getText(fieldName)} is required.
>> > >> label.name = Name
>> > >>
>> > >>
>> > >> When there is validation error, it looking for user.name property, it
>> > is
>> > >> fine because I'm using fieldName, so my question is there anyway I can
>> > get
>> > >> key name? So that I can use the label.name property.
>> > >>
>> > >>
>> > >> Regards
>> > >> LV
>> > >>
>> > >
>> > > --
>> > > View this message in context:
>> > http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.html
>> > > Sent from the Struts - User mailing list archive at Nabble.com.
>> > >
>> > >
>> > > ---------------------------------------------------------

-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer

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


Re: How to get the key name

Posted by ma...@yahoo.com.
Ok, now I know what you mean the key, you mean ${getText(label.name)} ?
But that is not that I want, if I hard code the key name there, that defeat the whole reuse purpose.
I want something similar like fieldName but for key. fieldName is a constant variable from struts, when I write the code like this
error.required = ${getText(fieldName)} is required.

and if I have these 2 tag in jsp:
<s:textfield key="label.name" name="user.name" maxlength="35" required="true"/>
<s:textfield key="label.email" name="user.email" maxlength="35" required="true"/>

In runtime when validation error, it will search for user.name and user.email property in the resource bundle files.

So, if I've this
user.name = Name
user.email = Email 
in the resource bundle files,

Then it will display correctly as
Name is required.
Email is required.

But in my resource bundle files, I only have
label.name = Name
label.email = Email

Which map to the key, so I need to find a way to get it.

Hope you can understand, sorry for my poor description.

Regards
LV




________________________________
From: Saeed Iqbal <sa...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thu, December 3, 2009 12:29:30 PM
Subject: Re: How to get the key name

No not that

key="i8nl.nameKey"

Send me your file

On Thu, Dec 3, 2009 at 5:27 PM, <ma...@yahoo.com> wrote:

> No, I changed my property to this
> error.required = ${getText(key)} is required.
>
> It is not working.
>
>
>
> ________________________________
> From: Saeed Iqbal <sa...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, December 3, 2009 9:56:29 AM
> Subject: Re: How to get the key name
>
> Yes key is in struts. See the docs.
>
> On Thu, Dec 3, 2009 at 2:54 PM, <ma...@yahoo.com> wrote:
>
> > Hi,
> >
> > Sorry, I think you misunderstanding my question.
> >
> > My main question is fieldName give me the name attribute value, but I
> want
> > to get my key attribute value, is there anything like fieldKey or
> something
> > ?
> >
> > <s:textfield key="label.name" name="user.name" maxlength="35"
> > required="true"/>
> >
> > fieldName = user.name
> >  ?? = label.name
> >
> > Thanks
> > LV
> >
> >
> >
> > ________________________________
> > From: Saeed Iqbal <sa...@gmail.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>
> > Sent: Thu, December 3, 2009 2:13:20 AM
> > Subject: Re: How to get the key name
> >
> > You use the key attribute instead of label
> >
> > On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
> > >
> > > Try this,
> > >
> > > <s:text name="label.name" />
> > > <s:textfield name="user.name" maxlength="35" required="true"/>
> > >
> > > -siddiq.
> > >
> > >
> > > Louis Voo wrote:
> > >>
> > >> Hi,
> > >>
> > >> I've this text field in my jsp
> > >>
> > >> <s:textfield key="label.name" name="user.name" maxlength="35"
> > >> required="true"/>
> > >>
> > >> and this property in the resource bundle
> > >>
> > >> error.required = ${getText(fieldName)} is required.
> > >> label.name = Name
> > >>
> > >>
> > >> When there is validation error, it looking for user.name property, it
> > is
> > >> fine because I'm using fieldName, so my question is there anyway I can
> > get
> > >> key name? So that I can use the label.name property.
> > >>
> > >>
> > >> Regards
> > >> LV
> > >>
> > >
> > > --
> > > View this message in context:
> > http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
> > >
> > >
> >
> > --
> > Saeed Iqbal
> > Independant Consultant (Freelance)
> > J2EE - Application Architect / Developer
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
>
> --
> Saeed Iqbal
> Independant Consultant (Freelance)
> J2EE - Application Architect / Developer
>



-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer

Re: How to get the key name

Posted by Saeed Iqbal <sa...@gmail.com>.
No not that

key="i8nl.nameKey"

Send me your file

On Thu, Dec 3, 2009 at 5:27 PM, <ma...@yahoo.com> wrote:

> No, I changed my property to this
> error.required = ${getText(key)} is required.
>
> It is not working.
>
>
>
> ________________________________
> From: Saeed Iqbal <sa...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, December 3, 2009 9:56:29 AM
> Subject: Re: How to get the key name
>
> Yes key is in struts. See the docs.
>
> On Thu, Dec 3, 2009 at 2:54 PM, <ma...@yahoo.com> wrote:
>
> > Hi,
> >
> > Sorry, I think you misunderstanding my question.
> >
> > My main question is fieldName give me the name attribute value, but I
> want
> > to get my key attribute value, is there anything like fieldKey or
> something
> > ?
> >
> > <s:textfield key="label.name" name="user.name" maxlength="35"
> > required="true"/>
> >
> > fieldName = user.name
> >  ?? = label.name
> >
> > Thanks
> > LV
> >
> >
> >
> > ________________________________
> > From: Saeed Iqbal <sa...@gmail.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>
> > Sent: Thu, December 3, 2009 2:13:20 AM
> > Subject: Re: How to get the key name
> >
> > You use the key attribute instead of label
> >
> > On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
> > >
> > > Try this,
> > >
> > > <s:text name="label.name" />
> > > <s:textfield name="user.name" maxlength="35" required="true"/>
> > >
> > > -siddiq.
> > >
> > >
> > > Louis Voo wrote:
> > >>
> > >> Hi,
> > >>
> > >> I've this text field in my jsp
> > >>
> > >> <s:textfield key="label.name" name="user.name" maxlength="35"
> > >> required="true"/>
> > >>
> > >> and this property in the resource bundle
> > >>
> > >> error.required = ${getText(fieldName)} is required.
> > >> label.name = Name
> > >>
> > >>
> > >> When there is validation error, it looking for user.name property, it
> > is
> > >> fine because I'm using fieldName, so my question is there anyway I can
> > get
> > >> key name? So that I can use the label.name property.
> > >>
> > >>
> > >> Regards
> > >> LV
> > >>
> > >
> > > --
> > > View this message in context:
> > http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
> > >
> > >
> >
> > --
> > Saeed Iqbal
> > Independant Consultant (Freelance)
> > J2EE - Application Architect / Developer
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
>
> --
> Saeed Iqbal
> Independant Consultant (Freelance)
> J2EE - Application Architect / Developer
>



-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer

Re: How to get the key name

Posted by ma...@yahoo.com.
No, I changed my property to this
error.required = ${getText(key)} is required.

It is not working.



________________________________
From: Saeed Iqbal <sa...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thu, December 3, 2009 9:56:29 AM
Subject: Re: How to get the key name

Yes key is in struts. See the docs.

On Thu, Dec 3, 2009 at 2:54 PM, <ma...@yahoo.com> wrote:

> Hi,
>
> Sorry, I think you misunderstanding my question.
>
> My main question is fieldName give me the name attribute value, but I want
> to get my key attribute value, is there anything like fieldKey or something
> ?
>
> <s:textfield key="label.name" name="user.name" maxlength="35"
> required="true"/>
>
> fieldName = user.name
>  ?? = label.name
>
> Thanks
> LV
>
>
>
> ________________________________
> From: Saeed Iqbal <sa...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, December 3, 2009 2:13:20 AM
> Subject: Re: How to get the key name
>
> You use the key attribute instead of label
>
> On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
> >
> > Try this,
> >
> > <s:text name="label.name" />
> > <s:textfield name="user.name" maxlength="35" required="true"/>
> >
> > -siddiq.
> >
> >
> > Louis Voo wrote:
> >>
> >> Hi,
> >>
> >> I've this text field in my jsp
> >>
> >> <s:textfield key="label.name" name="user.name" maxlength="35"
> >> required="true"/>
> >>
> >> and this property in the resource bundle
> >>
> >> error.required = ${getText(fieldName)} is required.
> >> label.name = Name
> >>
> >>
> >> When there is validation error, it looking for user.name property, it
> is
> >> fine because I'm using fieldName, so my question is there anyway I can
> get
> >> key name? So that I can use the label.name property.
> >>
> >>
> >> Regards
> >> LV
> >>
> >
> > --
> > View this message in context:
> http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
> >
> >
>
> --
> Saeed Iqbal
> Independant Consultant (Freelance)
> J2EE - Application Architect / Developer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>



-- 
Saeed Iqbal
Independant Consultant (Freelance)
J2EE - Application Architect / Developer

Re: How to get the key name

Posted by Saeed Iqbal <sa...@gmail.com>.
Yes key is in struts. See the docs.

On Thu, Dec 3, 2009 at 2:54 PM, <ma...@yahoo.com> wrote:

> Hi,
>
> Sorry, I think you misunderstanding my question.
>
> My main question is fieldName give me the name attribute value, but I want
> to get my key attribute value, is there anything like fieldKey or something
> ?
>
> <s:textfield key="label.name" name="user.name" maxlength="35"
> required="true"/>
>
> fieldName = user.name
>  ?? = label.name
>
> Thanks
> LV
>
>
>
> ________________________________
> From: Saeed Iqbal <sa...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, December 3, 2009 2:13:20 AM
> Subject: Re: How to get the key name
>
> You use the key attribute instead of label
>
> On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
> >
> > Try this,
> >
> > <s:text name="label.name" />
> > <s:textfield name="user.name" maxlength="35" required="true"/>
> >
> > -siddiq.
> >
> >
> > Louis Voo wrote:
> >>
> >> Hi,
> >>
> >> I've this text field in my jsp
> >>
> >> <s:textfield key="label.name" name="user.name" maxlength="35"
> >> required="true"/>
> >>
> >> and this property in the resource bundle
> >>
> >> error.required = ${getText(fieldName)} is required.
> >> label.name = Name
> >>
> >>
> >> When there is validation error, it looking for user.name property, it
> is
> >> fine because I'm using fieldName, so my question is there anyway I can
> get
> >> key name? So that I can use the label.name property.
> >>
> >>
> >> Regards
> >> LV
> >>
> >
> > --
> > View this message in context:
> http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
> >
> >
>
> --
> Saeed Iqbal
> Independant Consultant (Freelance)
> J2EE - Application Architect / Developer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>



-- 
Saeed Iqbal
Independant Consultant (Freelance)
J2EE - Application Architect / Developer

Re: How to get the key name

Posted by ma...@yahoo.com.
Hi,

Sorry, I think you misunderstanding my question.

My main question is fieldName give me the name attribute value, but I want to get my key attribute value, is there anything like fieldKey or something ?

<s:textfield key="label.name" name="user.name" maxlength="35" required="true"/>

fieldName = user.name
 ?? = label.name 

Thanks
LV



________________________________
From: Saeed Iqbal <sa...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thu, December 3, 2009 2:13:20 AM
Subject: Re: How to get the key name

You use the key attribute instead of label

On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
>
> Try this,
>
> <s:text name="label.name" />
> <s:textfield name="user.name" maxlength="35" required="true"/>
>
> -siddiq.
>
>
> Louis Voo wrote:
>>
>> Hi,
>>
>> I've this text field in my jsp
>>
>> <s:textfield key="label.name" name="user.name" maxlength="35"
>> required="true"/>
>>
>> and this property in the resource bundle
>>
>> error.required = ${getText(fieldName)} is required.
>> label.name = Name
>>
>>
>> When there is validation error, it looking for user.name property, it is
>> fine because I'm using fieldName, so my question is there anyway I can get
>> key name? So that I can use the label.name property.
>>
>>
>> Regards
>> LV
>>
>
> --
> View this message in context: http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
>
>

-- 
Saeed Iqbal
Independant Consultant (Freelance)
J2EE - Application Architect / Developer

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

Re: How to get the key name

Posted by Saeed Iqbal <sa...@gmail.com>.
You use the key attribute instead of label

On Wednesday, December 2, 2009, Siddiq Syed <si...@yahoo.com> wrote:
>
> Try this,
>
> <s:text name="label.name" />
> <s:textfield name="user.name" maxlength="35" required="true"/>
>
> -siddiq.
>
>
> Louis Voo wrote:
>>
>> Hi,
>>
>> I've this text field in my jsp
>>
>> <s:textfield key="label.name" name="user.name" maxlength="35"
>> required="true"/>
>>
>> and this property in the resource bundle
>>
>> error.required = ${getText(fieldName)} is required.
>> label.name = Name
>>
>>
>> When there is validation error, it looking for user.name property, it is
>> fine because I'm using fieldName, so my question is there anyway I can get
>> key name? So that I can use the label.name property.
>>
>>
>> Regards
>> LV
>>
>
> --
> View this message in context: http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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
>
>

-- 
Saeed Iqbal
Independant Consultant (Freelance)
J2EE - Application Architect / Developer

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


Re: How to get the key name

Posted by Siddiq Syed <si...@yahoo.com>.
Try this,

<s:text name="label.name" />
<s:textfield name="user.name" maxlength="35" required="true"/>

-siddiq.


Louis Voo wrote:
> 
> Hi,
> 
> I've this text field in my jsp
> 
> <s:textfield key="label.name" name="user.name" maxlength="35"
> required="true"/>
> 
> and this property in the resource bundle
> 
> error.required = ${getText(fieldName)} is required.
> label.name = Name
> 
> 
> When there is validation error, it looking for user.name property, it is
> fine because I'm using fieldName, so my question is there anyway I can get
> key name? So that I can use the label.name property.
> 
> 
> Regards
> LV
> 

-- 
View this message in context: http://old.nabble.com/How-to-get-the-key-name-tp26613714p26613875.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