CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 User Localised DatePicker Popup

Print topic Send  topic

Author Message
Anton Hinxman
Posted: 03/24/2004, 2:07 AM

Win2K Pro, IE6 SP6, Tomcat JSP 5.0.18, MySQL 4.0.18-max, Ant 1.6.1, JavaScript 5.6.0.8515

DatePicker uses hard coded format string found in the JavaScript for the control:

YourDateControl_DatePicker_fieldcoldate.format = "dd/mm/yyyy";

So when we have to cater for the US how do we change this hard coded format so that the same application works for us here in the UK as well as the USA?

Let's just say I can reliably find the users locale but I see no way to dynamically change the fixed JavaScript with comes with this CCS control.

It would appear as if I have to drop the use of the date picker and use something like the date popup scripts found in:

http://www.mattkruse.com/

Any other ideas?

Anton

peterr


Posts: 5971
Posted: 03/25/2004, 11:13 AM

The date format can be changed in the site's or control's properties, then the JavaScript will be regenerated with the appropriate format.

Interestingly, when I go to www.lufthansa.com and http://www.easyjet.com I can only use the non-US date format DD/MM/YYYY (I am in the US).

In our case you could probably change the JavaScript to:
YourDateControl_DatePicker_fieldcoldate.format = "{MyFormat}";
and then modify {MyFormat} dynamically at runtime. I'll check exactly how.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
peterr


Posts: 5971
Posted: 03/26/2004, 12:34 AM

Actually, looks like you can put the above code in the JavaScript section of HTML but use a Label for {MyFormat}, then replace the Label at run-time as shown at http://docs.codecharge.com/studio/html/
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Anton
Posted: 03/26/2004, 2:10 AM

Thanks, I came to a similar conclusion with:

YourDateControl_DatePicker_fieldcoldate.format = "{MyFormat}";

So, looking at the docs, and from what I understand of CCS....

"A common 'trick' with CCS is to define a Label control with HTML settings and then redefine it at runtime to anything you want. This would enable the control to appear as 'read only' or carry any other attributes you want or even be redefined as an entry TextBox."

Looking at it all again, I think that I would prefer the simplest solution which appears to be to define {MyFormat} as shown in "Working with Custom Template Blocks".

So if I imagine that the template for the page is XML we have something like:

Template tmpl = e.getPage().getTemplate();
String currentPath = e.getPage().getCurrentPath();
tmpl.setVar(currentPath+ "/SomePathElements/@MyFormat", "dd/MM/yyyy");
tmpl.parse(currentPath+ "/SomePathElements");

What I think is going on here is that the XML to govern the page is being amended to include a dynamic insert into one of its tree branches. The value assigned can then be used to present the page via macro substitution in the HTML.

It's the 'SomePathElements' depth I do not understand - where is a {MyFormat} in the tree of elements?

I also see what you are saying about the Label. The label could exist at the page level and then (somehow) the value is picked up by the {MyFormat} template macro substitution. The label then need only be dynamically redefined as a hidden textbox.

It could be that I have got the concept slightly wrong in that a variable exists (is scoped) for the PAGE if no path is set?

I will go for the variable insert route because it is more generic and user cut&paste of a page reveals all your hidden data to a user.

tmpl.setVar(currentPath+ "/SomePathElements/@MyFormat", "dd/MM/yyyy");

What is the correct SomePathElements ?

TIA

Anton
peterr


Posts: 5971
Posted: 03/26/2004, 8:38 AM

Please try:
tmpl.setVar(currentPath+ "/@MyFormat", "dd/MM/yyyy"); 
And in case of a Label:
// Label Before Show  
 e.getControl().setFormattedValue("dd/MM/yyyy");   
Or
// Page Before Show   
e.getPage().getControl("MyFormat").setFormattedValue("dd/MM/yyyy");  

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Anton
Posted: 03/30/2004, 12:28 PM

Many thanks - looking into it.

Anton

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.