cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for a particular UI element

Former Member
0 Kudos

Hello,

At htmlb and in many SAP apps there is the following UI:

An input field with a little square besides it. Pressing the suqare opens date navigator and selecting a certain date sets it inside the input field. Is there such a ready-made UI at DynPro as well?

Roy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create a context attribute of type "date" and assign the context to a inputfield.

During runtime automatically you will get a dropdown where you can navigate through a calender.

Regards, Anilkumar

Former Member
0 Kudos

Wow so simple! 10X a lot Anilkumar, points are on their way 2 u...

Former Member
0 Kudos

By the way, is is possible to allow the user to enter a date only from this date navigator and to block him from writing it on his own at the input field?

Answers (7)

Answers (7)

Former Member
0 Kudos

error in posting....

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hi,

Go to browser settings , Tools -> Internet Options -> Languages .

Here set the language to English - United Kingdom.

In your code

SimpleDateFormat SDF = new SimpleDateFormat();

wdContext.currentContextElement().setDt(Date.valueOf("1900-2-23"));

You can use this if u have this standard format.

Otherwise..

SimpleDateFormat SDF = new SimpleDateFormat(<"the format of date">);

wdContext.currentContextElement().setDt(SDF.parse("the string date"));

Extremely sorry ! Forget to mention that Dt is of type java.sql.Date...

Regards

Bharathwaj

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hi Roy,

Your requirement being to set the value for the date input field.. you cant do that in the code level.

If you want the value in the input field to displayed in dd\mm\yyyy format switch ur browser language to English-UK.

(I dont know if their is any language setting which gives date in the format of dd\mm\yy).

You cant create a date object in the format you want. You can only parse the object and get it into a formatted string to suit ur requirement

Regards

Bharathwaj

Former Member
0 Kudos

Hey Bharathwaj,

OK, So assuming I will be using the format: dd\mm\yyyy.

How do I create a java.sql.Date object which contains today's date with the above format?

Former Member
0 Kudos

Hi,

java.sql.Date d = new Date(System.currentTimeMillis());

wdComponentAPI.getMessageManager().reportWarning(""+d);

SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yy");

wdComponentAPI.getMessageManager().reportWarning(sdf.format(d));

This will give you the system date in dd/mm/yy format.

Is that wat u want ?

oops ! sorry ! I think u want the dd/mm//yy string as a java.sql.Date ?? Just tell me if i my understanding of your question is correct ?

Regards

Bharathwaj

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hey Bharathwaj,

What I need is to create an Object from type java.sql.Date that contains today's date in this format: dd/mm/yy. Any idea how to acheive this?

Former Member
0 Kudos

SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yy");

wdComponentAPI.getMessageManager().reportSuccess("date :"+sdf.format(d));

Date ddd=new Date((new java.util.Date(sdf.format(dt))).getTime());

wdComponentAPI.getMessageManager().reportSuccess("Date"+ddd);

regards

noufal

Former Member
0 Kudos

But than again ddd is of type java.util.Date

I need an Object of type java.sal.Date that contains today's date in the format: dd/MM/yy

Former Member
0 Kudos

no ddd can be of time java.sql.Date which has a constructor Date(long).

I'm sorry I didn't specify it correctly

The other Date I have used is of type java.util.Date(), I thought you would notice.

Regards

Noufal

Former Member
0 Kudos

Hey Noufal,

I am sorry but I'm a bit confused here.

You are using dt in your code, who is dt?

Can you please show me the code from the begining with an output of java.sql.Date() with the rwquired format?

Former Member
0 Kudos

Hi,

Check this

Regards, Anilkumar

Former Member
0 Kudos

Hi,

I feel for this create a simpleType of type date and set the representaion as per the requirement.

Regards, Anilkumar

Former Member
0 Kudos

I did that: I've creates simpleType of type date and at it's representation tab under "Format" I put: dd/mm/yyyy and bound the relevant Context to this simpleType but it still behaves as before...

Former Member
0 Kudos

Hi Roy,

Th Date Picker takes the format from the ur Browser Settings .That is the reason even if u set the format in the representaion of the simple type ur r still getting the same.

If u change the LanguagePreference from English-US to English-UK.It will show dd/mm/yyyy format.

Regards,

Sowjanya.

Former Member
0 Kudos

You are right 10X.

Do u happen to know also how can I disable the option to enter the date manually into the input field? I would like the user to enter it only from the Date Picker...

Former Member
0 Kudos

Hi ,

I think it is not possible with current versions bcoz if

u set the properties to disable the input field the date picker will also get disabled.

Even if teh user enters in a wrong format in the input field the error handling in webdynpro will throw an error to enter the correct format.

Regards,

Sowjanya.

Former Member
0 Kudos

OK, and is it possible on load to take the current date from the Date Picker and put it inside the input field as a default date?

Former Member
0 Kudos

Hi Roy,

U can get current date and set it to teh attribute of type Date that is bound to the Inputfiled.

Date date = new Date(System.currentTimeMillis());

wdContext.currentContextElement().setVaDate(date);

Regards,

Sowjanya.

Former Member
0 Kudos

Oh 10X that I know, I just thought that there is a design attribute that I've missed that can do that

Former Member
0 Kudos

Well, it seems I encounter a problem here.

The Context date is java.sal.Date.

I am using DateFormat in order to transform the current Date into a String of the type: dd/mm/yy.

Any idea how I combine this String with java.sal.Date Object? This object doesn't have String at his Contstructor...

Former Member
0 Kudos

What exactly do you mean with "Any idea how I combine this String with java.sql.Date Object?"?

If you want to create a java.sql.Date instance from a string, you can use the method java.sql.Date.valueOf(String) which expects the string to have the form "yyyy-mm-dd".

Armin

Former Member
0 Kudos

Hey Armin,

But both me and the Date Context are using the format: dd/mm/yy and this methos expects the string to have the form "yyyy-mm-dd".

Former Member
0 Kudos

Hi

Just Check whether this is useful for you

java.sql.Date dt = new java.sql.Date(System.currentTimeMillis());

SimpleDateFormat sdfinput = new SimpleDateFormat("yyyy-MM-dd");

SimpleDateFormat sdfout = new SimpleDateFormat("dd/MM/yyyy");

Date dt1 = null;

try {

dt1 = sdfinput.parse(dt.toString());

String str = sdfinput.format(dt1).toString();

System.out.println(str);

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

sdfout.format(dt1);

System.out.println(sdfout.format(dt1));

Former Member
0 Kudos

10X Guys but these won't help.

If you'll notice, DynPro is using java.sql.Date and there is no way, as far as I know, to use the parse on this Object.

krish, in your code for example I need dt1 to be java.sql.Date and not java.util.Date.

To summerise, I need to create an Object from type java.sql.Date that contains today's date in this format: dd/mm/yy. Any idea how to acheive this?

Roy

Former Member
0 Kudos

For my knowldege the user can only select the date from the list and he can't enter any values in the inputfield.

Regards, Anilkumar

Former Member
0 Kudos

1. Well, I've tested it and he can.

2. And another q if you don't mind: When I select the date it puts it in MM/DD/YY Format at the input field. Is there any way to "tell" it to set it at DD/MM/YY Format?