You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mleneveut <ML...@abusinessware.com> on 2007/10/10 09:14:18 UTC
[S2] How to apply a Java method on a ${myVarInStack} in a JSP ?
Hi all,
I just give up the datetimepicker component, due to a 2s more page load
time. I put anoter JS calendar (YUI calendar), but the problem is that in my
Actions I have java.util.Date attributes. So I need to format my Date into a
String that the calendar will understand (dd/MM/yyyy in my case). When I
submit the form I have no problem, Struts converts the dd/MM/yyyy String
into a java.util.Date.
So my question is : How to apply a Java method on a ${myDate} in the JSP ?
Without Struts I would have done :
<% Date myDate = (Date)request.getAttribute("myDate");%>
<%=com.myorg.util.DateManipulation.format(myDate)%>
Or another question : What is the best (most beautiful) way to format all
java.util.Date to dd/MM/yyyy String from Actions to JSP ? Interceptor ?
Overide Struts Converters ? The point is that I will need localization.
Thanks for your help.
Michaël
--
View this message in context: http://www.nabble.com/-S2--How-to-apply-a-Java-method-on-a-%24%7BmyVarInStack%7D-in-a-JSP---tf4598988.html#a13130629
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
Re: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?
Posted by mleneveut <ML...@abusinessware.com>.
Ok sorry for stupid question, I have found :)
<s:date name="myDate" format="%{getText('date.format')}" var
="myDateFormatted"/>
<s:textfield id="date" name="date"
size="10" maxlength = "10"
value="${myDateFormatted}"/>
mleneveut wrote:
>
> Thanks for your answer.
>
> The s:date tag is fine, but how to pass it to a s:textfield tag ?
>
> <s:textfield id="date" name="date"
> size="10" maxlength = "10"
> value="<s:date name="myDate" format="%{getText('date.format')}"/>"/>
>
>
>
> maxmil wrote:
>>
>> You can call a static method using the OGNL syntax.
>>
>> <s:property value="@com.myorg.util.DateManipulation@format(myDate)" />.
>>
>> (More info can be found here
>> http://www.opensymphony.com/ognl/html/LanguageGuide/)
>>
>> However i suggest you have a look at the s:date tag.
>>
>> max
>>
>
>
--
View this message in context: http://www.nabble.com/-S2--How-to-apply-a-Java-method-on-a-%24%7BmyVarInStack%7D-in-a-JSP---tf4598988.html#a13132034
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
Re: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?
Posted by mleneveut <ML...@abusinessware.com>.
Thanks for your answer.
The s:date tag is fine, but how to pass it to a s:textfield tag ?
<s:textfield id="date" name="date"
size="10" maxlength = "10"
value="<s:date name="myDate" format="%{getText('date.format')}"/>"/>
maxmil wrote:
>
> You can call a static method using the OGNL syntax.
>
> <s:property value="@com.myorg.util.DateManipulation@format(myDate)" />.
>
> (More info can be found here
> http://www.opensymphony.com/ognl/html/LanguageGuide/)
>
> However i suggest you have a look at the s:date tag.
>
> max
>
--
View this message in context: http://www.nabble.com/-S2--How-to-apply-a-Java-method-on-a-%24%7BmyVarInStack%7D-in-a-JSP---tf4598988.html#a13131826
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
Re: [S2] How to apply a Java method on a ${myVarInStack} in a JSP
?
Posted by Max Pimm <ma...@alwayssunny.com>.
You can call a static method using the OGNL syntax.
<s:property value="@com.myorg.util.DateManipulation@format(myDate)" />.
(More info can be found here
http://www.opensymphony.com/ognl/html/LanguageGuide/)
However i suggest you have a look at the s:date tag.
max
mleneveut wrote:
> Hi all,
>
> I just give up the datetimepicker component, due to a 2s more page load
> time. I put anoter JS calendar (YUI calendar), but the problem is that in my
> Actions I have java.util.Date attributes. So I need to format my Date into a
> String that the calendar will understand (dd/MM/yyyy in my case). When I
> submit the form I have no problem, Struts converts the dd/MM/yyyy String
> into a java.util.Date.
>
> So my question is : How to apply a Java method on a ${myDate} in the JSP ?
> Without Struts I would have done :
> <% Date myDate = (Date)request.getAttribute("myDate");%>
> <%=com.myorg.util.DateManipulation.format(myDate)%>
>
> Or another question : What is the best (most beautiful) way to format all
> java.util.Date to dd/MM/yyyy String from Actions to JSP ? Interceptor ?
> Overide Struts Converters ? The point is that I will need localization.
>
> Thanks for your help.
>
>
> Michaël
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?
Posted by Martin Gainty <mg...@hotmail.com>.
take a look at accessor and mutator for 'page' in the ViewSourceAction.java sourceMartin Gainty______________________________________________Disclaimer and confidentiality noteEverything 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.> From: mgainty@hotmail.com> To: user@struts.apache.org> Subject: RE: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?> Date: Wed, 10 Oct 2007 08:49:29 -0400> > > Here is an example from struts2-showcasehttp://localhost:8080/struts2-showcase/viewSource.action?page=/ajax/autocompleter/index.jsppage is referenced from webapp/viewSource.jsp e.g.> <h3>${empty page ? "Unknown page" : page}</h3>> which populates page and renders> <h3>/ajax/autocompleter/index.jsp</h3>> Martin ______________________________________________Disclaimer and confidentiality noteEverything 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, 10 Oct 2007 00:14:18 -0700> From: MLENEVEUT@abusinessware.com> To: user@struts.apache.org> Subject: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?> > > Hi all,> > I just give up the datetimepicker component, due to a 2s more page load> time. I put anoter JS calendar (YUI calendar), but the problem is that in my> Actions I have java.util.Date attributes. So I need to format my Date into a> String that the calendar will understand (dd/MM/yyyy in my case). When I> submit the form I have no problem, Struts converts the dd/MM/yyyy String> into a java.util.Date.> > So my question is : How to apply a Java method on a ${myDate} in the JSP ?> Without Struts I would have done : > <% Date myDate = (Date)request.getAttribute("myDate");%>> <%=com.myorg.util.DateManipulation.format(myDate)%>> > Or another question : What is the best (most beautiful) way to format all> java.util.Date to dd/MM/yyyy String from Actions to JSP ? Interceptor ?> Overide Struts Converters ? The point is that I will need localization.> > Thanks for your help.> > > Michaël> -- > View this message in context: http://www.nabble.com/-S2--How-to-apply-a-Java-method-on-a-%24%7BmyVarInStack%7D-in-a-JSP---tf4598988.html#a13130629> 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> > _________________________________________________________________> Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now.> http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
_________________________________________________________________
Climb to the top of the charts! Play Star Shuffle: the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct
RE: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?
Posted by Martin Gainty <mg...@hotmail.com>.
Here is an example from struts2-showcasehttp://localhost:8080/struts2-showcase/viewSource.action?page=/ajax/autocompleter/index.jsppage is referenced from webapp/viewSource.jsp e.g.
<h3>${empty page ? "Unknown page" : page}</h3>
which populates page and renders
<h3>/ajax/autocompleter/index.jsp</h3>
Martin ______________________________________________Disclaimer and confidentiality noteEverything 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, 10 Oct 2007 00:14:18 -0700> From: MLENEVEUT@abusinessware.com> To: user@struts.apache.org> Subject: [S2] How to apply a Java method on a ${myVarInStack} in a JSP ?> > > Hi all,> > I just give up the datetimepicker component, due to a 2s more page load> time. I put anoter JS calendar (YUI calendar), but the problem is that in my> Actions I have java.util.Date attributes. So I need to format my Date into a> String that the calendar will understand (dd/MM/yyyy in my case). When I> submit the form I have no problem, Struts converts the dd/MM/yyyy String> into a java.util.Date.> > So my question is : How to apply a Java method on a ${myDate} in the JSP ?> Without Struts I would have done : > <% Date myDate = (Date)request.getAttribute("myDate");%>> <%=com.myorg.util.DateManipulation.format(myDate)%>> > Or another question : What is the best (most beautiful) way to format all> java.util.Date to dd/MM/yyyy String from Actions to JSP ? Interceptor ?> Overide Struts Converters ? The point is that I will need localization.> > Thanks for your help.> > > Michaël> -- > View this message in context: http://www.nabble.com/-S2--How-to-apply-a-Java-method-on-a-%24%7BmyVarInStack%7D-in-a-JSP---tf4598988.html#a13130629> 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>
_________________________________________________________________
Windows Live Hotmail and Microsoft Office Outlook – together at last. Get it now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033