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: [email protected]
> To: [email protected]; [email protected]
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
_________________________________________________________________
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/