on 10-14-2005 12:26 PM
Hi
I have requirement in which the present month and year is read and next 12 months are displayed. Each being displayed as row in the table???
e.g. : The present Month is Ocotber'05
Then entries in the table will be:
October'05
November'05
........
........
May '06
June'06
.......
.......
September '06
Thanks and regards
Srikant
Hi Srikant,
You are creating an elemnt of the root context when you say 'wdContext.createContextElement();'
Instead create elements of the node that you have bound to your table. As told earlier, create a string attribute inside this node.
So replace the two lines
IPrivatePreBuyView.IContextElement monthElement;
and
wdContext.createContextElement();
with
IPrivatePreBuyView.I<your_table_node>Element monthElement;
and
wdContext.create<your_table_node>Element();
But anyway, the values being generated do not depend on this. So
String month = (new SimpleDateFormat("MMMMMM yy").format(new java.util.Date(c.getTimeInMillis())));
and
wdComponentAPI.getMessageManager().reportSuccess("Month ::"+month);
should anyhow show you the generated month.
Please let us know if you still face any problems in implementing this.
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srikanth,
Is "Context" is the name of the node ??
If yes, then
//Setting the attribute 's value
monthElement.setCMonth(month);
wdContext.nodeContext().addElement(monthElement);
and place the following statement inside the forloop.
IPrivatePreBuyView.IContextElement monthElement;
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
helo DV,
u have to populate the table with 12 row ie u have to create 12 elements of the node and add it. u need to loop 12 times.
java.util.Date date = new Date(); // will return u the current date.
int month = date.getMonth(); // will return the int representation of the month field.
for(int i=0;i<12;i++)
{
if(month>11) month = 0;
// create and add the node elements...
// set the month field like this.
if(month==0)
element.setMonthField("JANUARY");
else if(month==1)
element.setMonthField("FEBRUARY");
...
...
...
month++;
}
u can use Calander class also.
Regards,
Piyush.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srikant,
Giving you a code sample for the same :
create a string attribute say 'month' in the node bound to your table.
// Getting the current time
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
// Creating 12 elements of the node bound to table
IPrivate<View>.I<your_node_name>Element elmt;
for(int i=0;i<12;i++)
{
elmt = wdContext.create<node>Element();
// incrementing the month
c.add( Calendar.MONTH,i );
// converting the time into the required format
String month = (new SimpleDateFormat("MMMMMM yy").format(new java.util.Date(c.getTimeInMillis())));
// setting the attribute's value
elmt.setMonth(month);
wdContext.node<Node_name>().addElement(elmt);
}
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nibu,
I binded string attribute to column. And i have followed the method which u shown but the its not displaying values.
I have to Month and year across each row of the table. So i added a column and binded it the string attribute with it.
Am i going somewhere wrong?? Please help
Thanks in advance
Srikant
Hi Srikant,
I am not sure abt what you missed. It works perfectly fine for me Anyway, after generating the values, try printing them to make sure that the data is generated correctly. Change your code like :
.
.
.
// converting the time into the required format
String month = (new SimpleDateFormat("MMMMMM yy").format(new java.util.Date(c.getTimeInMillis())));
<b>wdComponentAPI.getMessageManager().reportSuccess("Month ::"+month);</b>
// setting the attribute's value
elmt.setMonth(month);
.
.
.
Best Regards,
Nibu.
Hi Nibu,
I tried displaying the values of the month as you mentioned yet they are not able to display.
I have coded this in a void method. do i need to which returns void. do i need to change the return parameter? ( I think its not necessary)
my code looks like following:
public void DisplayMonth( )
{
//@@begin DisplayMonth()
//Getting Current Time
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
//Creating Node Elements
IPrivatePreBuyView.IContextElement monthElement;
for(int i=0; i<12; i++)
{
//Creating the context element
monthElement = wdContext.createContextElement();
//Incrementing the month
cal.add(Calendar.MONTH,i);
//Converting the time into required format
String month = (new SimpleDateFormat("MMMMMM yy").format(new java.util.Date(cal.getTimeInMillis())));
//Setting the attribute 's value
wdContext.addElement(monthElement);
monthElement.setCMonth(month);
}
Can you tell me where i might be going wrong??
Thanks in advance
Srikant
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.