cancel
Showing results for 
Search instead for 
Did you mean: 

populate dropdownwith key

Former Member
0 Kudos

Dear all,

I have a dropwdown box with key, Now my requirement is to fill this dropdown box with 30 dates..I tried it but getting runtime error. can anybody suggest a way out.

String datelist[] = new String[30];

SimpleDateFormat dtFormat = new SimpleDateFormat("dd.MM.yyyy");

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("days");

// ArrayList ldate = new ArrayList();

for (int i = 0; i < 31; ++i) {

datelist<i> = dtFormat.format(new java.util.Date());

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

values.put("i", "datelist<i>");

}

Regds

Anup

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Anup,

What is a type of "days" attribute?

See comments in the following code and use one form for "string" and other one for "date" types:


final Calendar calendar = Calendar.getInstance
(
  WDResourceHandler.getCurrentSessionLocale()
);

calendar.setTimeInMillis( System.currentTimeInMillis() ); 
final SimpleDateFormat dtFormat = new SimpleDateFormat("dd.MM.yyyy");
final ISimpleTypeModifiable myType=wdContext()
  .getModifiableTypeOf("days");

final IModifiableSimpleValueSet values = myType
  .getSVServices()
    .getModifiableSimpleValueSet();
values.clear();

/* 30 days from now */
for (int i = 0; i < 31; ++i) 
{
  final java.sql.Date date = 
    new java.sql.Date( calendar.getTimeInMillis() );

  final String dateStr = dtFormat.format( date );

  /* if type is <b>string</b> */
  values.put( dateStr, dateStr );
  /* else if type is <b>date</b> */
  values.put( date, dateStr ); 
  calendar.add( Calendar.DATE, 1 );
}

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Dear Valery,

The "days" attribute is of type string.

i have tried ur code but it is only showing the current date but i need thirty dates in the list from current date...Pls help..

Regds,

Anup

Former Member
0 Kudos

Dear Valery,

Thanks it is solved..

Full points...

Cheers..!!

Anup

Answers (0)