cancel
Showing results for 
Search instead for 
Did you mean: 

Using a DateNavigator as a CalendarYearView

Former Member
0 Kudos

Hi experts,

I write this thread to ask if it is possible to use a DateNavigator to highlight just some days, such as it is possible in a CalendarYearView, or in a CalendarWeekView.

In fact, I've followed the tutorial "Implementing a Calendar in Web Dynpro Java" made by Stefanie Bacher, so I've managed to create a correct CalendarYearView.

In an other way, I've create a range of highlighted days with the tutorial "JA310 - Java Web Dynpro Basics" (page 136).

But I can't manage to highlight just some days in the datenavigator. As far I've seeked, there is no tutorial that described how to do this.

If you know that's possible, could you help me doing this ?

Thank you for advance,

Louis

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member201361
Active Contributor
0 Kudos

Hi Louis,

u can use Marker Element to high light the date in the Date Navigator. in the Outline View , right click on Date Navigator --> Inset Marking .

Create a Node say "Test" and attribute "Date", bound a node to the data source property and set the date property with Date att

to the Marking element.

(u can use the semnatics property of Marking element to display the date in different colour)

using the below code to highlight the date in date navigator.

ITestElement element = wdCOntext.nodeTest().createTestElement();

element.setDate(dateValue);

wdContext.nodeTest().addElement(element);

Hope it helps,

Thanks and Regards,

Former Member
0 Kudos

Hi !

Thank you for your response.

I've try to implement it successfully, but if I've removed the errors, it doesn't display anything to me (even the datenavigator isn't displayed... I just have a blue page, without anything on it...).

Here is the code I've put in the wdDoInit method in the controller file :

public void wdDoInit()
  {
    //@@begin wdDoInit()
	  ITestElement element = wdContext.nodeTest().createTestElement();	  
	  element.setDate(CctDate.valueOf("2009-01-05"));
	  wdContext.nodeTest().addElement(element);
    //@@end
  }

Do you have an idea of what could solve it ?

Thank you for advance.

LOuis

former_member201361
Active Contributor
0 Kudos

Hi Louis,

here u are trying to set the CcTDate to Sql Date. it should show error in design time itself.

can u try it out in this way :

public void wdDoInit()

{

//@@begin wdDoInit()

ITestElement element = wdContext.nodeTest().createTestElement();

Calendar cal = Calendar.getInstance();

cal.set(Calendar.YEAR,2009);

cal.set(Calendar.DAY_OF_MONTH,01);

cal.set(Calendar.MONTH,05);

element.setDate(new Date(cal.getTimeInMillis()));

wdContext.nodeTest().addElement(element);

//@@end

}

Former Member
0 Kudos

Hi,

Thank you for your response.

I've just tried your code, and I have now two different errors, depending which package I import.

With the following imports:

import java.util.Calendar;
import java.util.Date;

I get the the "setDate" underlined, with the error message : "The method setDate(CctDate) in the type IPublicZemployee12.ITestElement is not applicable for the arguments (Date)".

-


With the following imports :

import java.util.Calendar;

import sun.util.calendar.BaseCalendar$Date;

I get the the "Date" underlined (in : new Date(cal.getTimeInMillis()) ), with the error message : "Date cannot be resolved to a type".

I have tried every possible imports I'm proposed, but everyone got an error...

I think the problem comes from the Date or setDate, but I haven't found any document on the web that could explain what method to use in the DateNavigator case.

If you have any idea to solve this, I'ld be very glad to try it.

Thank you for advance,

Louis

former_member201361
Active Contributor
0 Kudos

Hi Louis,

Please follow these steps:

1.Open the View --> in the Outline of ur View --> right click on Date Navigator --> insert Marking element.

2.Switch to context tab and create a node say "Test" of cardinality 0 to n.

3. to that node Test,create a attribute of type Date (sql Date).

4.bind Test node to data source property and date attribte to date property of marking element.

5. in the doInit method of view controller write this code:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,2009);
cal.set(Calendar.DAY OF MONTH,01);
cal.set(Calendar.MONTH,05);

ITestElement element = wdContext.nodeTest().createTestElement();
element.setDate(cal.getTimeInMillis());
wdContext.nodeTest().addElement(element);

Here Date is of Type java.sql.date

Calendar is Java.util.calendar.

to the Marking element, u can use semantics to high light the date. just change the semantics property to badvalue_dark.

hope it helps.

Thanks and Regards

Former Member
0 Kudos

Hi !

Thank you for your answers (and please pardon me for my late answer).

I've done exactly what you advised me, but I still have two errors :

wdContext.nodeTest().createTestElement(); is underlined, with the error : "Type mismatch: cannot convert from IPrivateZemployee12view.ITestElement to IPublicZemployee12.ITestElement"

And setDate is underlined to, with the error : "The method setDate(Date) in the type IPublicZemployee12.ITestElement is not applicable for the arguments (long)"

.

I have seen that getTimeInMillis gave a long result, but I don't really know what to give (what format) to setDate...

Do you have an idea that could solve those errors ?

Thank you for advance,

Regards.

Former Member
0 Kudos

Hi,

wdContext.nodeTest().createTestElement(); is underlined, with the error : "Type mismatch: cannot convert from IPrivateZemployee12view.ITestElement to IPublicZemployee12.ITestElement"

For this error Change the type of ITestElement to IPrivateZemployee12view

And setDate is underlined to, with the error : "The method setDate(Date) in the type IPublicZemployee12.ITestElement is not applicable for the arguments (long)"

Instead of using setDate(cal.getTimeInMillis()) use setDate(cal.getTime()) if the context attribute Date is of type java.util.Date otherwise create an java.sql.Date attribute and set the value to it using cal.getTimeInMillis().

Regards,

Gayathri

Former Member
0 Kudos

hi Fazal Ahamed,

I think I've gone forward.

I've put the entire code in the wdDoInit method of the component controller : and it has made the "Type mismatch: cannot convert from IPrivateZemployee12view.ITestElement to IPublicZemployee12.ITestElement" error disappear. Cool !

Now, I've just to try debbug the setDate function.

I think the error was due to the fact that the getTimeInMillis method was giving a "long", but the arguments of the setDate method must be of type "Date".

So I used the method getTime (instead of getTimeInMillis), because getTime gives a "Date" result.

So now the code is :

	  Calendar cal = Calendar.getInstance();
	  cal.set(Calendar.YEAR,2009);
	  cal.set(Calendar.DAY_OF_MONTH,01);
	  cal.set(Calendar.MONTH,05);
	  ITestElement element = wdContext.nodeTest().createTestElement();
	  element.setDate(cal.getTime());
	  wdContext.nodeTest().addElement(element);

But the setDate method still tells me :

"The method setDate(Date) in the type IPublicZemployee12.ITestElement is not applicable for the arguments (Date)"

Do someone know how to fix this ? Because I do not know what to do know...

Regards

former_member201361
Active Contributor
0 Kudos

Hi Louis,

setDate() is requires java.sq.Date and u are trying to set Long Value to it.

use this code :

Calendar cal = Calendar.getInstance();
	  cal.set(Calendar.YEAR,2009);
	  cal.set(Calendar.DAY_OF_MONTH,01);
	  cal.set(Calendar.MONTH,05);
	  ITestElement element = wdContext.nodeTest().createTestElement();
                        Date sqlDate = new Date(cal.getTimeInMillis());
	  element.setDate(sqlDate);
	  wdContext.nodeTest().addElement(element);

thanks and regards

Edited by: Fazal Ahamed on Sep 4, 2009 4:21 PM

Former Member
0 Kudos

Hi Gayathri Kavi,

Thank you for your answer.

I've tried your advices, but it doesn't change the errors :

>

>wdContext.nodeTest().createTestElement(); is underlined, with the error : "Type mismatch: cannot convert from >IPrivateZemployee12view.ITestElement to IPublicZemployee12.ITestElement"

>

>For this error Change the type of ITestElement to IPrivateZemployee12view

After doing this, the error shown is : "Type mismatch: cannot convert from IPrivateZemployee12view.ITestElement to

IPrivateZemployee12view"

I don't understand exactly why the same message is shown (I've shut down and then reload NWDS to check, but I've still the same error...), even if I've change the type of the variable "element"...

>

And setDate is underlined to, with the error : "The method setDate(Date) in the type >IPublicZemployee12.ITestElement is not applicable for the arguments (long)"

>

>Instead of using setDate(cal.getTimeInMillis()) use setDate(cal.getTime()) if the context attribute Date is of type java.util.Date >otherwise create an java.sql.Date attribute and set the value to it using cal.getTimeInMillis().

I've done this, and I still have a weird error: "The method setDate(Date) is undefined for the type IPrivateZemployee12view"

But thank you for your answer. I'm sure we'll find !

former_member201361
Active Contributor
0 Kudos

Hi Louis,

wdContext.nodeTest().createTestElement(); is underlined, with the error : "Type mismatch: cannot convert from IPrivateZemployee12view.ITestElement to IPublicZemployee12.ITestElement"

its just a simple type mismatch problem.what u have to do, change ITestElement to IPrivateZemployee12view.

1.in the View controller java editor , remove the line where type mismatch is problem exits.

just type : ITestE then CTRL+SPACE --> here u will get two options say IPrivateZemployee12view.ITestElement and IPublicZemployee12.ITestElement. in this select IPrivateZemployee12.ITestElement.

ITestElement element = wdContext.nodeTest().createtTestElement();

with this ur problem will be solved.

Former Member
0 Kudos

Hi Fazal:

I've managed to have no more errors !

I've just modified a little bit the last code you gave me (writing getTime instead of getTimeInMillis). The final code is :

Calendar cal = Calendar.getInstance();

cal.set(Calendar.YEAR,2009);

cal.set(Calendar.DAY_OF_MONTH,01);

cal.set(Calendar.MONTH,05);

ITestElement element = wdContext.nodeTest().createTestElement();

Date sqlDate = new Date(cal.getTimeInMillis());

element.setDate(sqlDate);

wdContext.nodeTest().addElement(element);

This doesn't occurs me any error.

But during building, I get an error, and the execution of the application make me an error 500. I don't really think it's the fault of this particularly code, I'll try to identify from where it comes.

But thank you Fazal !

Thank you all !