You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Heligon Sandra <sa...@thomson.net> on 2003/04/01 09:33:13 UTC

HELP: Dispaly Date in a JSP that used Tiles

	I am really desperate. I try to display the current date in a JSP
but that does not function. 
	I found many examples of Javascript (aff_heure()) on the Web but the
difficulty is to combine them with 
 	the Struts components and more precisely Tiles components.
	Each page of the application has the same look: a header, a menu, a
body and a footer.
	And I have a main layout.jsp that each page has to extend:
	<html:html locale="true">
	<head>
 		<title><tiles:getAsString name="title"/></title>
	</head>
	<body onload= "aff_heure()" bgcolor="#ffffff" text="#000000"
link="#023264" alink="#023264" vlink="#023264">
	<table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
    		<td width="140"  valign="top" height="23"><tiles:insert
attribute="header"/></td>
   		 <td width="100%" colspan="3"  align="left"><tiles:insert
attribute="menu"/></td>
	  </tr>
  	  <tr>
	    	<td valign="top"  align="center"><tiles:insert
attribute='body' /> </td>
  	  </tr>
  	   <tr>
      		<tiles:insert attribute="footer" />
  	   </tr>
	</table>
	</body>
	</html:html>
	In the header.jsp I have defined the aff_heure() script:

	<table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<script type="text/javascript">
		      function aff_heure() {
	                  var d=new Date()
                              var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
)
                              var monthname=new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec
")
                              document.write(weekday[d.getDay()] + " ")
	                  document.write(d.getDate() + ". ")
	                  document.write(monthname[d.getMonth()] + " ")
                              document.write(d.getFullYear()+ ",")
                              document.write(d.getHours())
                              document.write(":")
                              document.write(d.getMinutes())        
		      document.write(":")
		      document.write(d.getSeconds())
		      setTimeout("aff_heure()",10000);
     		}
     		</script>
		<noscript><bean:message
key="label.javascript.required"/></noscript>
	  </tr>
	</table>

	This code doesn't work, the page displayed only a number. 
	 If somebody succeeded in posting the current date/time thank you
very much to indicate the solution to me 


----------------------------------------------------------------------------

As of February 12th, 2003 Thomson unifies its email addresses on a worldwide
basis. 
Please note my new email address: sandra.heligon@thomson.net 

http://www.thomson.net/ 


Re: a small query

Posted by Nicolas De Loof <ni...@cgey.com>.
Using resourceBundle for application messages has some advantages :
- application can be localized easily if needed
- messages can be updated without recompile
- messages can be managed by customers on deployed app if they want
- bundle can be sent to customer for update / validation
- developers doesn't have to search some docs for the error message in some business case. They just define a new bundel
entry with some explicit name.

Nico.

> hi,
> firstly, i am very new to struts. these questions may sound very basic.
> my application has put all the text content to be seen in the view in
> .properties files.
>
> what is the need purpose  to take data from the file.properties files?
>
> is it only for multi lingual sites? or any other reasons?
>
> how do i know that an application is support different languages.
>
> balraj
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


a small query

Posted by Balraj Goulikar <ba...@codecindia.com>.
hi,
firstly, i am very new to struts. these questions may sound very basic.
my application has put all the text content to be seen in the view in
.properties files.

what is the need purpose  to take data from the file.properties files?

is it only for multi lingual sites? or any other reasons?

how do i know that an application is support different languages.

balraj



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


localize messages in JSP without session

Posted by Nicolas De Loof <ni...@cgey.com>.
On logon.jsp I would like messages to be localized. AFAIK to do this with Struts I have to put this tags :

<html:html locale="true">
  <bean:message key="logon.welcome" />
...
</html:html>

This tags use a Locale objet stored in session scope. My boss doesn't want this logon JSP to create a new session to
limit memory usage. Is they're a way to use Struts i18n with a REQUEST scoped Locale or something like this ?

Do you thing it could be an interseting enhancement for future versions ?

Nico.


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


Re: HELP: Dispaly Date in a JSP that used Tiles

Posted by Stephen Smithstone <sk...@lchost.co.uk>.
in respect to that dont you need to implement the date text into a text box 
container ?

On Tuesday 01 April 2003 8:43 am, Stephen Smithstone wrote:
> ah sorry missed your timer function
>
> On Tuesday 01 April 2003 8:41 am, Stephen Smithstone wrote:
> > wow all that trouble for a date what i would do is create a TileAction
> > that sets up the date variable in the tiles context and then publish that
> > attribute on the tiles page
> >
> > public class TilesDate extends TileAction
> > {
> >
> >  public void perform( ComponentContext 1 , HttpServletRequest 2 ,
> > HttpServletResponse 3 , ServletContext 4 )
> > {
> >
> >   SimpleDateFormat sdf = new SimpleDateFormat( "dd:MM:yyyy" );
> >
> >  1.putAttribute( "date" , sdf.format( new java.util.Date( ) );
> >
> >
> >
> > }
> >
> >
> > then in my tiles-def.xml
> >
> >  i would have
> >
> > <definition controllerUrl="/TilesDate.do" name="portal.main"
> > page="/layouts/layout1.jsp">
> >   </definition>
> >
> > in the struts-config
> >
> > define the TilesDate actionMapping
> >
> > then call my tiles from an action forward using portal.main
> >
> > thats just my view thou
> >
> > On Tuesday 01 April 2003 8:33 am, Heligon Sandra wrote:
> > > 	I am really desperate. I try to display the current date in a JSP
> > > but that does not function.
> > > 	I found many examples of Javascript (aff_heure()) on the Web but the
> > > difficulty is to combine them with
> > >  	the Struts components and more precisely Tiles components.
> > > 	Each page of the application has the same look: a header, a menu, a
> > > body and a footer.
> > > 	And I have a main layout.jsp that each page has to extend:
> > > 	<html:html locale="true">
> > > 	<head>
> > >  		<title><tiles:getAsString name="title"/></title>
> > > 	</head>
> > > 	<body onload= "aff_heure()" bgcolor="#ffffff" text="#000000"
> > > link="#023264" alink="#023264" vlink="#023264">
> > > 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> > > 	  <tr>
> > >     		<td width="140"  valign="top" height="23"><tiles:insert
> > > attribute="header"/></td>
> > >    		 <td width="100%" colspan="3"  align="left"><tiles:insert
> > > attribute="menu"/></td>
> > > 	  </tr>
> > >   	  <tr>
> > > 	    	<td valign="top"  align="center"><tiles:insert
> > > attribute='body' /> </td>
> > >   	  </tr>
> > >   	   <tr>
> > >       		<tiles:insert attribute="footer" />
> > >   	   </tr>
> > > 	</table>
> > > 	</body>
> > > 	</html:html>
> > > 	In the header.jsp I have defined the aff_heure() script:
> > >
> > > 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> > > 	  <tr>
> > > 		<script type="text/javascript">
> > > 		      function aff_heure() {
> > > 	                  var d=new Date()
> > >                               var weekday=new
> > > Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Satu
> > >rd ay " )
> > >                               var monthname=new
> > > Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov"
> > >," De c ")
> > >                               document.write(weekday[d.getDay()] + " ")
> > > 	                  document.write(d.getDate() + ". ")
> > > 	                  document.write(monthname[d.getMonth()] + " ")
> > >                               document.write(d.getFullYear()+ ",")
> > >                               document.write(d.getHours())
> > >                               document.write(":")
> > >                               document.write(d.getMinutes())
> > > 		      document.write(":")
> > > 		      document.write(d.getSeconds())
> > > 		      setTimeout("aff_heure()",10000);
> > >      		}
> > >      		</script>
> > > 		<noscript><bean:message
> > > key="label.javascript.required"/></noscript>
> > > 	  </tr>
> > > 	</table>
> > >
> > > 	This code doesn't work, the page displayed only a number.
> > > 	 If somebody succeeded in posting the current date/time thank you
> > > very much to indicate the solution to me
> > >
> > >
> > > -----------------------------------------------------------------------
> > >-- -- -
> > >
> > > As of February 12th, 2003 Thomson unifies its email addresses on a
> > > worldwide basis.
> > > Please note my new email address: sandra.heligon@thomson.net
> > >
> > > http://www.thomson.net/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: HELP: Dispaly Date in a JSP that used Tiles

Posted by Stephen Smithstone <sk...@lchost.co.uk>.
ah sorry missed your timer function

On Tuesday 01 April 2003 8:41 am, Stephen Smithstone wrote:
> wow all that trouble for a date what i would do is create a TileAction that
> sets up the date variable in the tiles context and then publish that
> attribute on the tiles page
>
> public class TilesDate extends TileAction
> {
>
>  public void perform( ComponentContext 1 , HttpServletRequest 2 ,
> HttpServletResponse 3 , ServletContext 4 )
> {
>
>   SimpleDateFormat sdf = new SimpleDateFormat( "dd:MM:yyyy" );
>
>  1.putAttribute( "date" , sdf.format( new java.util.Date( ) );
>
>
>
> }
>
>
> then in my tiles-def.xml
>
>  i would have
>
> <definition controllerUrl="/TilesDate.do" name="portal.main"
> page="/layouts/layout1.jsp">
>   </definition>
>
> in the struts-config
>
> define the TilesDate actionMapping
>
> then call my tiles from an action forward using portal.main
>
> thats just my view thou
>
> On Tuesday 01 April 2003 8:33 am, Heligon Sandra wrote:
> > 	I am really desperate. I try to display the current date in a JSP
> > but that does not function.
> > 	I found many examples of Javascript (aff_heure()) on the Web but the
> > difficulty is to combine them with
> >  	the Struts components and more precisely Tiles components.
> > 	Each page of the application has the same look: a header, a menu, a
> > body and a footer.
> > 	And I have a main layout.jsp that each page has to extend:
> > 	<html:html locale="true">
> > 	<head>
> >  		<title><tiles:getAsString name="title"/></title>
> > 	</head>
> > 	<body onload= "aff_heure()" bgcolor="#ffffff" text="#000000"
> > link="#023264" alink="#023264" vlink="#023264">
> > 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> > 	  <tr>
> >     		<td width="140"  valign="top" height="23"><tiles:insert
> > attribute="header"/></td>
> >    		 <td width="100%" colspan="3"  align="left"><tiles:insert
> > attribute="menu"/></td>
> > 	  </tr>
> >   	  <tr>
> > 	    	<td valign="top"  align="center"><tiles:insert
> > attribute='body' /> </td>
> >   	  </tr>
> >   	   <tr>
> >       		<tiles:insert attribute="footer" />
> >   	   </tr>
> > 	</table>
> > 	</body>
> > 	</html:html>
> > 	In the header.jsp I have defined the aff_heure() script:
> >
> > 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> > 	  <tr>
> > 		<script type="text/javascript">
> > 		      function aff_heure() {
> > 	                  var d=new Date()
> >                               var weekday=new
> > Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturd
> >ay " )
> >                               var monthname=new
> > Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","
> >De c ")
> >                               document.write(weekday[d.getDay()] + " ")
> > 	                  document.write(d.getDate() + ". ")
> > 	                  document.write(monthname[d.getMonth()] + " ")
> >                               document.write(d.getFullYear()+ ",")
> >                               document.write(d.getHours())
> >                               document.write(":")
> >                               document.write(d.getMinutes())
> > 		      document.write(":")
> > 		      document.write(d.getSeconds())
> > 		      setTimeout("aff_heure()",10000);
> >      		}
> >      		</script>
> > 		<noscript><bean:message
> > key="label.javascript.required"/></noscript>
> > 	  </tr>
> > 	</table>
> >
> > 	This code doesn't work, the page displayed only a number.
> > 	 If somebody succeeded in posting the current date/time thank you
> > very much to indicate the solution to me
> >
> >
> > -------------------------------------------------------------------------
> >-- -
> >
> > As of February 12th, 2003 Thomson unifies its email addresses on a
> > worldwide basis.
> > Please note my new email address: sandra.heligon@thomson.net
> >
> > http://www.thomson.net/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: HELP: Dispaly Date in a JSP that used Tiles

Posted by Stephen Smithstone <sk...@lchost.co.uk>.
wow all that trouble for a date what i would do is create a TileAction that 
sets up the date variable in the tiles context and then publish that 
attribute on the tiles page

public class TilesDate extends TileAction
{

 public void perform( ComponentContext 1 , HttpServletRequest 2 , 
HttpServletResponse 3 , ServletContext 4 )
{

  SimpleDateFormat sdf = new SimpleDateFormat( "dd:MM:yyyy" );

 1.putAttribute( "date" , sdf.format( new java.util.Date( ) );

 

}


then in my tiles-def.xml

 i would have 

<definition controllerUrl="/TilesDate.do" name="portal.main" 
page="/layouts/layout1.jsp">
  </definition>

in the struts-config

define the TilesDate actionMapping

then call my tiles from an action forward using portal.main

thats just my view thou
On Tuesday 01 April 2003 8:33 am, Heligon Sandra wrote:
> 	I am really desperate. I try to display the current date in a JSP
> but that does not function.
> 	I found many examples of Javascript (aff_heure()) on the Web but the
> difficulty is to combine them with
>  	the Struts components and more precisely Tiles components.
> 	Each page of the application has the same look: a header, a menu, a
> body and a footer.
> 	And I have a main layout.jsp that each page has to extend:
> 	<html:html locale="true">
> 	<head>
>  		<title><tiles:getAsString name="title"/></title>
> 	</head>
> 	<body onload= "aff_heure()" bgcolor="#ffffff" text="#000000"
> link="#023264" alink="#023264" vlink="#023264">
> 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> 	  <tr>
>     		<td width="140"  valign="top" height="23"><tiles:insert
> attribute="header"/></td>
>    		 <td width="100%" colspan="3"  align="left"><tiles:insert
> attribute="menu"/></td>
> 	  </tr>
>   	  <tr>
> 	    	<td valign="top"  align="center"><tiles:insert
> attribute='body' /> </td>
>   	  </tr>
>   	   <tr>
>       		<tiles:insert attribute="footer" />
>   	   </tr>
> 	</table>
> 	</body>
> 	</html:html>
> 	In the header.jsp I have defined the aff_heure() script:
>
> 	<table border="0" width="100%" cellspacing="0" cellpadding="0">
> 	  <tr>
> 		<script type="text/javascript">
> 		      function aff_heure() {
> 	                  var d=new Date()
>                               var weekday=new
> Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday
>" )
>                               var monthname=new
> Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","De
>c ")
>                               document.write(weekday[d.getDay()] + " ")
> 	                  document.write(d.getDate() + ". ")
> 	                  document.write(monthname[d.getMonth()] + " ")
>                               document.write(d.getFullYear()+ ",")
>                               document.write(d.getHours())
>                               document.write(":")
>                               document.write(d.getMinutes())
> 		      document.write(":")
> 		      document.write(d.getSeconds())
> 		      setTimeout("aff_heure()",10000);
>      		}
>      		</script>
> 		<noscript><bean:message
> key="label.javascript.required"/></noscript>
> 	  </tr>
> 	</table>
>
> 	This code doesn't work, the page displayed only a number.
> 	 If somebody succeeded in posting the current date/time thank you
> very much to indicate the solution to me
>
>
> ---------------------------------------------------------------------------
>-
>
> As of February 12th, 2003 Thomson unifies its email addresses on a
> worldwide basis.
> Please note my new email address: sandra.heligon@thomson.net
>
> http://www.thomson.net/


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