cancel
Showing results for 
Search instead for 
Did you mean: 

How to do this in WebDynpro?

Former Member
0 Kudos

Hi all,

I have a requirement like in my view there will be two popup buttons from where i can select Dates and the there will be one more button, when i click on this, it should display the difference between the 2 selected dates. How this could be done in WD.

Any ideas.....help me

Thanks in advance

regards,

Ganesh

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try this:

1. In your view, have two input fields for the two date objects. Bind them to two different context attributes of type date.

2. This will give you two buttons next to the two input fields. On click of these buttons, you will get the calendar pop up from where you can select the dates.

3. Now in your view have one more button and attach a event say "calculateDateDiff" to the onAction event of this button.

4. In the eventhandler for this event, use the following code:


java.util.Date date1 = wdContext.currentContextElement.getDateOne();

java.util.Date date2 = wdContext.currentContextElement.getDateTwo();

Calendar cal1 = null; 
Calendar cal2 = null;
        
cal1=Calendar.getInstance(); 
cal2=Calendar.getInstance(); 
        
// different date might have different offset
cal1.setTime(date1);          
long ldate1 = date1.getTime() + cal1.get(Calendar.ZONE_OFFSET) + cal1.get(Calendar.DST_OFFSET);
        
cal2.setTime(date2);
long ldate2 = date2.getTime() + cal2.get(Calendar.ZONE_OFFSET) + cal2.get(Calendar.DST_OFFSET);
        
// Use integer calculation, truncate the decimals
int hr1   = (int)(ldate1/3600000); //60*60*1000
int hr2   = (int)(ldate2/3600000);

int days1 = (int)hr1/24;
int days2 = (int)hr2/24;
        
int dateDiff  = days2 - days1;

Bind this dateDiff to some context attribute of type int and then push it to your view.

Regards,

Satyajit.

P.S. You need to close your previous threads.

Former Member
0 Kudos

Hi,

I have created 2 input fields and bound the two to two context attributes of type Date. But i could not get the buttons next to them. Can you be more clear how to bind? May be i went wrong some where.!

<b>>>2.This will give you two buttons next to the two input fields. On click of these buttons, you will get the calendar pop up from where you can select the dates.</b>

Please suggest me

Thanks a lot

Former Member
0 Kudos

Hi ganesh,

If you have the context attribute of type date, then it brings small button next to inputfields. Did you get this?

Kind Regards,

Saravanan K

Former Member
0 Kudos

Hi,

Create two context attributes of type date. Select this "date" from the dropdown that you get when you go to the "type" property of the context attribute.

Don't select java native type.

Bind these attributes to the "value" property of the inputfields.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

I created two variables in Context by selecting value attributes of type date.

<b>Then for inputfield1 value i selected date1 which is my context attribute (of type date), i have done same for inputfield2.</b>Still i could not get the small buttons as you said.

Plesae suggest me

Thanks a lot

Former Member
0 Kudos

Hi

I have created a View and created 2 input fields and on the <b>value</b> i selected date1 which is my context attribute (of type date). I created exactly like what you said:

>>Create two context attributes of type date. Select this "date" from the dropdown that you get when you go to the "type" property of the context attribute.

Even i have given value as 3 for Colcount of RootUIElementContainer. What else to do and where I went wrong?

Help me

Thanks

Former Member
0 Kudos

HI,

If you deploy the application, wat you get. Give some text in that inputfield and check whether it is date attribute.Give date format in that without popup.

Try this

Kind regards,

Saravanan K

Former Member
0 Kudos

Hi,

What does it show when you run the application? Only a inputfield?

You don't need to do anything with the colCount property.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

I have not written a single line of code, and deployed and the result is nothing... not even my input fields are not displayed. <b>Any code is to be implemented? if so where do i implement the code in which methodds? what exactly is the code that i should write?</b>. Please help me.

Thanks a lot

Former Member
0 Kudos

Hi,

Kindly do it in the doInit() method and check whether the visible property of the input field is set to visible?and check the window's visible is visible.Kindly feedback other components are visible?

regards,

Saravanan K

Former Member
0 Kudos

Hi,

It is not necessary to write any methods to implement. Just bind the attributes to the UIElements

Regards,

Saravanan K

Former Member
0 Kudos

Hi all,

Thanks for all your patience. Can any one of you give me a step by step procedure as how to develop this.

I have done all as what you people said, but still i could not able to get those small buttons in my View.

Please suggest me

Thanks a lot

Former Member
0 Kudos

Hi,

1.First create two context attributes and set the type "DATE" using the dropdown in the properties of context attribute.

2.Create two inputfields in the view and bind those attributes to the inputfields. Ensure these inputfields are visible.

3.No coding is necessary.Deploy the application and give some string in the date inputfields to ensure it is date type.

Hope this will help you.

Regards,

Saravanan K

Former Member
0 Kudos

Hi,

Can you tell us the step by step procedure that you have followed?

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

I followed as what you and saravanan said.

First created 2 input fields and bound context values of type date. Then deployed and it worked.

Thanks anyway, for all

regards,

Ganesh

Former Member
0 Kudos

Hi,

Great. Please close this thread, if your problem has been solved.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

I have changed some part of design and added date diff to <b>calculate difference between the 2 dates and deployed, but

am not getting the effect a button is added and one input is also added these 2 are not coming when i deploy and ran the same application</b>. How to rectify this? and also let me know how to close the thread

regards,

Ganesh

Former Member
0 Kudos

Hi,

1. Apart from the two inputfields that you have defined for the two dates, you must have created one more inputfield to display the date difference. Bind the "value" property of this inputfield to some context attribute, say DateDifference, of type String.

2. You must have created a button on click of which you need to calculate the date difference. For the OnAction event of this button, write the code to calculate the difference of dates.

3. Now after you have calculated the date difference and stored in some local variable say dateDiff, write this code:


wdContext.currentContextElement.setDateDifference(dateDiff);

4. Build and deploy and run your application. Tell us what you get.

Btw you can close a thread by marking one of the answers as "Solved Problem" or your own post as "Solved on my own".

Regards,

Satyajit.

Former Member
0 Kudos

Dear jonna,

You can parse the month, day, year, hour second from the dates and calculate the difference.

Kind regards,

Saravanan K

former_member85655
Active Participant
0 Kudos

Assuming that u have bound the UI elements to context attribtutes date1 and date2 . You can do this

Date date1 = wdcontext.nodeXX().currentElement().getAttributeValue("Date1");

Date date2 = wdcontext.nodeXX().currentElement().getAttributeValue("Date2");

diff = date1- date2;

wdcontext.nodeXX().currentElement().setAttributeValue("Diff",diff);

Regards,

Arun