You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2009/02/04 22:50:43 UTC
getText did not return value in s:submit
Good afternoon,
A question about getText in jsp file. I'd like to get value from
property file.
in package.properties,
edit.action=Edit information
in jsp,
...
<s:i18n name="info.ProcessInfo">
<s:form action="ProcessInfo" >
<s:submit name="submit" value="%{getText('edit.action')}" />
</s:form>
</s:i18n>
The result always shows "edit.action" as the button value, but not "Edit
information". Could someone tell me where I did wrong please?
Thanks
--
Lu Ying
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
Finally, in JSP(not through action) success by doing the following:
(1) Create "struts.properties" under WEB-INF/classes/
struts.custom.i18n.resources=globalMessages
(2) Create globalMessages_en_US.properties
label.test= test label value
(3) in JSP,
<s:label value="%{getText('label.test')}" />
--
Lu Ying
> Emi Lu wrote:
>>> http://t.wits.sg/2008/06/23/howto-struts-2-i18n/
>> Did not success.
>>
>> (1) in package.properties
>> label.code=example value
>>
>> (2) Put package.properties under /WEB-INF/classes/
>>
>>
>> (3) in jsp
>> <s:label value="label.code" />
>>
>> Still cannot see the result?
>
> Again: are you accessing the JSP through an action?
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Steven Yang <ke...@gmail.com>.
>
>
>> (2) Put package.properties under /WEB-INF/classes/
>>
>>
> have you tried to put package.properties under the same package as your
action class?AFAIK package.properties only works with classes in the same
package or classes sub-classing the classes in the package.
Re: getText did not return value in s:submit
Posted by Dave Newton <ne...@yahoo.com>.
Emi Lu wrote:
>> http://t.wits.sg/2008/06/23/howto-struts-2-i18n/
> Did not success.
>
> (1) in package.properties
> label.code=example value
>
> (2) Put package.properties under /WEB-INF/classes/
>
>
> (3) in jsp
> <s:label value="label.code" />
>
> Still cannot see the result?
Again: are you accessing the JSP through an action?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
> http://t.wits.sg/2008/06/23/howto-struts-2-i18n/
Did not success.
(1) in package.properties
label.code=example value
(2) Put package.properties under /WEB-INF/classes/
(3) in jsp
<s:label value="label.code" />
Still cannot see the result?
--
Lu Ying
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Felipe Fraga <fe...@gmail.com>.
Pretty straight forward tutorial:
http://t.wits.sg/2008/06/23/howto-struts-2-i18n/
Best regards,
Felipe Fraga
On Thu, Feb 5, 2009 at 5:29 PM, Emi Lu <em...@encs.concordia.ca> wrote:
> Hi Dave,
>
>>> (3) but I do not know how jsp can recognize "package.properties"?
>>
>> You're mis-understanding how the text is retrieved from the JSP: the JSP
>> is calling the action's getText(...) method.
>>
>> Are you accessing the JSP directly, or through an action?
>
> I am new to struts2. I tried to use getText directly in JSP. Is it possible
> that I can use getText() to read values from packages.properties?
>
> Basically, in packages.properties
> message.info=value of the info
>
>
>
> in jsp, I'd like to display
> <s:textfield value="getText('message.info')" />
>
>
> Thanks a lot!
> --
> Lu Ying
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: getText did not return value in s:submit
Posted by Martin Gainty <mg...@hotmail.com>.
Good Evening Lu-
there is a good illustration of this resolution of getText available in Struts 2.1.2 editEmployee.jsp the example is a textfield which pulls attribute firstName from employee
<s:form name="editForm" action="save">
<s:textfield label="Employee Id" name="currentEmployee.empId"/>
<s:textfield label="%{getText('employee.firstName')}" name="currentEmployee.firstName"/>
here is the definition for 'save' method defined for EmployeeAction in struts.xml:
<action name="save" class="org.apache.struts2.showcase.action.EmployeeAction" method="save">
<result name="input">/empmanager/editEmployee.jsp</result>
<result type="redirect">edit-${currentEmployee.empId}.action</result>
</action>
public class EmployeeAction extends AbstractCRUDAction implements Preparable {
private static final long serialVersionUID = 7047317819789938957L;
private static final Logger log = Logger.getLogger(EmployeeAction.class);
private Long empId;
protected EmployeeDao employeeDao;
private Employee currentEmployee; //Note the reference to Employee here
.......
}
and finally the Employee Class
public class Employee implements IdEntity {
private static final long serialVersionUID = -6226845151026823748L;
private Long empId; //textfield w/ conversion
private String firstName; //the sought after firstName attribute
private String lastName; //the sought after lastName attribute
....
}
HTH
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.
> Date: Thu, 5 Feb 2009 12:29:46 -0500
> From: emilu@encs.concordia.ca
> To: user@struts.apache.org; newton.dave@yahoo.com
> Subject: Re: getText did not return value in s:submit
>
> Hi Dave,
>
> >> (3) but I do not know how jsp can recognize "package.properties"?
> >
> > You're mis-understanding how the text is retrieved from the JSP: the JSP
> > is calling the action's getText(...) method.
> >
> > Are you accessing the JSP directly, or through an action?
>
> I am new to struts2. I tried to use getText directly in JSP. Is it
> possible that I can use getText() to read values from packages.properties?
>
> Basically, in packages.properties
> message.info=value of the info
>
>
>
> in jsp, I'd like to display
> <s:textfield value="getText('message.info')" />
>
>
> Thanks a lot!
> --
> Lu Ying
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Stay up to date on your PC, the Web, and your mobile phone with Windows Live.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093185mrt/direct/01/
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
Hi Dave,
>> (3) but I do not know how jsp can recognize "package.properties"?
>
> You're mis-understanding how the text is retrieved from the JSP: the JSP
> is calling the action's getText(...) method.
>
> Are you accessing the JSP directly, or through an action?
I am new to struts2. I tried to use getText directly in JSP. Is it
possible that I can use getText() to read values from packages.properties?
Basically, in packages.properties
message.info=value of the info
in jsp, I'd like to display
<s:textfield value="getText('message.info')" />
Thanks a lot!
--
Lu Ying
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Dave Newton <ne...@yahoo.com>.
Emi Lu wrote:
>
>> I got why: I have to name the same property file name as the action
>> class. Rename "package.properties" to ProcessInfo.properties, I got
>> correct result.
>>
>> I just wonder isn't "package.properties" is recognized automatically?
>>
>> May I know how to use "package.properties" to display getText() in jsp
>> please?
>
> More testing results are:
>
> (1) Action class can recognize both "ProcessInfo.properties" and
> "package.properties"
>
> (2) JSP recognized "ProcessInfo.properties"
>
> (3) but I do not know how jsp can recognize "package.properties"?
You're mis-understanding how the text is retrieved from the JSP: the JSP
is calling the action's getText(...) method.
Are you accessing the JSP directly, or through an action?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
> I got why: I have to name the same property file name as the action
> class. Rename "package.properties" to ProcessInfo.properties, I got
> correct result.
>
> I just wonder isn't "package.properties" is recognized automatically?
>
> May I know how to use "package.properties" to display getText() in jsp
> please?
More testing results are:
(1) Action class can recognize both "ProcessInfo.properties" and
"package.properties"
(2) JSP recognized "ProcessInfo.properties"
(3) but I do not know how jsp can recognize "package.properties"?
--
Lu Ying
>>
>>> Take a look at this example
>>>
>>> <s:property value="%{getText('edit.action')}" />
>>> what is displayed when property is displayed in jsp?
>>
>> I got the same value displayed "edit.action" :( Do you know where I
>> did wrong please?
>>>> A question about getText in jsp file. I'd like to get value from
>>>> property file.
>>>>
>>>> in package.properties,
>>>> edit.action=Edit information
>>>>
>>>>
>>>> in jsp,
>>>> ...
>>>> <s:i18n name="info.ProcessInfo">
>>>> <s:form action="ProcessInfo" >
>>>> <s:submit name="submit" value="%{getText('edit.action')}" />
>>>> </s:form>
>>>> </s:i18n>
>>>>
>>>>
>>>> The result always shows "edit.action" as the button value, but not
>>>> "Edit information". Could someone tell me where I did wrong please?
>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
Good morning,
I got why: I have to name the same property file name as the action
class. Rename "package.properties" to ProcessInfo.properties, I got
correct result.
I just wonder isn't "package.properties" is recognized automatically?
May I know how to use "package.properties" to display getText() in jsp
please?
Thanks a lot!
--
Lu Ying
> Hi Martin,
>
>
>> Take a look at this example
>>
>> <s:property value="%{getText('edit.action')}" />
>> what is displayed when property is displayed in jsp?
>
> I got the same value displayed "edit.action" :( Do you know where I did
> wrong please?
>>> A question about getText in jsp file. I'd like to get value from
>>> property file.
>>>
>>> in package.properties,
>>> edit.action=Edit information
>>>
>>>
>>> in jsp,
>>> ...
>>> <s:i18n name="info.ProcessInfo">
>>> <s:form action="ProcessInfo" >
>>> <s:submit name="submit" value="%{getText('edit.action')}" />
>>> </s:form>
>>> </s:i18n>
>>>
>>>
>>> The result always shows "edit.action" as the button value, but not
>>> "Edit information". Could someone tell me where I did wrong please?
>>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: getText did not return value in s:submit
Posted by Emi Lu <em...@encs.concordia.ca>.
Hi Martin,
> Take a look at this example
>
> <s:property value="%{getText('edit.action')}" />
>
> what is displayed when property is displayed in jsp?
I got the same value displayed "edit.action" :( Do you know where I did
wrong please?
Thanks a lot!
--
Lu Ying
>
>
>
>
>> Date: Wed, 4 Feb 2009 16:50:43 -0500
>> From: emilu@encs.concordia.ca
>> To: user@struts.apache.org
>> Subject: getText did not return value in s:submit
>>
>> Good afternoon,
>>
>> A question about getText in jsp file. I'd like to get value from
>> property file.
>>
>> in package.properties,
>> edit.action=Edit information
>>
>>
>> in jsp,
>> ...
>> <s:i18n name="info.ProcessInfo">
>> <s:form action="ProcessInfo" >
>> <s:submit name="submit" value="%{getText('edit.action')}" />
>> </s:form>
>> </s:i18n>
>>
>>
>> The result always shows "edit.action" as the button value, but not "Edit
>> information". Could someone tell me where I did wrong please?
>>
>> Thanks
>> --
>> Lu Ying
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> Windows Live™: E-mail. Chat. Share. Get more ways to connect.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_022009
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: getText did not return value in s:submit
Posted by Martin Gainty <mg...@hotmail.com>.
Take a look at this example
<s:property value="%{getText('edit.action')}" />
what is displayed when property is displayed in jsp?
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.
> Date: Wed, 4 Feb 2009 16:50:43 -0500
> From: emilu@encs.concordia.ca
> To: user@struts.apache.org
> Subject: getText did not return value in s:submit
>
> Good afternoon,
>
> A question about getText in jsp file. I'd like to get value from
> property file.
>
> in package.properties,
> edit.action=Edit information
>
>
> in jsp,
> ...
> <s:i18n name="info.ProcessInfo">
> <s:form action="ProcessInfo" >
> <s:submit name="submit" value="%{getText('edit.action')}" />
> </s:form>
> </s:i18n>
>
>
> The result always shows "edit.action" as the button value, but not "Edit
> information". Could someone tell me where I did wrong please?
>
> Thanks
> --
> Lu Ying
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Windows Live™: E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_022009