cancel
Showing results for 
Search instead for 
Did you mean: 

Hardcode the values in the table

Former Member
0 Kudos

Hiii

Iam developing a web dynpro application.With out writing the code i can able to deploy and run the application.In that i want to hardcode values in the table for demo purpose.how i can get those values.

Is there any property in web dynpro to do that,,,,,,,, or else,,,,,,,,, we have to write the code in the application.

If thats the case,,,,Please provide the code to get the values in the table.

Regards

Sushma

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can implement a supply function for the data source node which creates and adds context elements containing the dummy data.

Armin

Answers (12)

Answers (12)

Former Member
0 Kudos

thanks

Former Member
0 Kudos

Hi Sushma,

Either you will have to take 8 arraylists and then use them as I told you in 1 of my earlier post. You can put the termination condition on any of the arraylist. At the start of this method declare the arraylist:

ArrayList Designation= new ArrayList();

then you can add your values to the arraylist like:

Designation.add("String");

Or you will have to follow the process that is create an element, set it and then bind it as already told to you. These 3 lines will have to be used exactly the number of times you have to set the values.

Regards.

Rajat

Former Member
0 Kudos

Hi Sushma,

You will have to create the element , set it and bind the number of times you have equal to the number of values to be set. Simpler way can be :

1) Take the values in a arraylist.

2) Keep the three lines of the following code in a for loop.

for(int i=0;i<arraylist.size();i++){

IPrivateTableCompView.INamesElement elem=node.createNamesElement();

elem.setFname(fnamearraylist.getElementat(i));

elem.setLname(lnamearraylist.getElementat(i));

node.addElement(i,elem);

}

Hope it helps.

Regards.

Rajat

Former Member
0 Kudos

Hi Rajat,,,

I tried like this also.......But iam not getting the solution.....

My table elements are

Designation,department,EmailID,EmpCode,EmpName,MobileNo,Slno,Location....

Regards

Sushma

Former Member
0 Kudos

HI,

this is because u are adding the same element.

create another instance elem1, elem2 .... for each row . refer to my previous post.

Regards,

Satya.

Former Member
0 Kudos

Hi

Satya ,,,for every time to add values to the each and every row .....we have to copy the code of one element to the other element.Is there any simple way to get this.

regards

Sushma

Former Member
0 Kudos

Hi

For different data,,,,,in what way i have to do.

Like this your saying

IPrivateEtrecEmpView.IEmployeeElement element4 = wdContext.nodeEmployee().createEmployeeElement();

element4.setDesignation("Software Engineer");

element4.setDepartment("Basis");

element4.setEmailID("");

element4.setEmpCode("0011579");

element4.setEmpName("");

element4.setMobileNo("");

element4.setSlno("4");

element4.setLocation("Bangalore");

wdContext.nodeEmployee().addElement(element4);

IPrivateEtrecEmpView.IEmployeeElement element3 = wdContext.nodeEmployee().createEmployeeElement();

element3.setDesignation("Software Engineer");

lement3.setDepartment("Web dynpro");

element3.setEmailID("");

element3.setEmpCode("0011579");

element3.setEmpName("");

element3.setMobileNo("");

element3.setSlno("4");

element3.setLocation("Bangalore");

wdContext.nodeEmployee().addElement(element3);

Former Member
0 Kudos

Hi,

Some times, if u recreate your node and forget to apply the template again

it will not work. just try deleting the table ui and apply a table template and try.

Regards,

Satya.

Former Member
0 Kudos

Hiii,

Iam able to get one row values in the table.But i want to get for 5 rows ......

For same rows what i have to write the code..

For different values what i have to write the code.

regards

Sushma

Former Member
0 Kudos

Hi Sushma,

Please have a look at my earlier post, there is a third line of code to add the element to the node. Unless and until you add or bind the element to the node, data will not be shown in the drop down or table.

Regards.

Rajat

Former Member
0 Kudos

Hi

I implemented the code like this in my application(init method) to provide dummy values to the table.

Its not showing error in the code ,,,, but its not displaying the data at the output of table.

Is there any need to provide the supply function,

If thats the case ,,, will anyone Please tell me in what way i have to proceed.

IPrivateEtrecEmpView.IEmployeeElement element = wdContext.nodeEmployee().createEmployeeElement();

element.setDesignation("Software Engineer");

element.setDepartment("Web Dynpro");

element.setEmailID("");

element.setEmpCode("00115f7");

element.setEmpName("Sushma");

element.setMobileNo("97425766uyui");

element.setSlno("1");

element.setLocation("Bangalore");

wdContext.nodeEmployee().addElement(element);

Regards

Sushma

Former Member
0 Kudos

No, you don't need both, but the supply function solution is more efficient. Have you correctly defined the data binding of the table (Table.dataSource = node Employee)?

Armin

Former Member
0 Kudos

HI ,

u can also do like this

IPrivateTableCompView.INamesNode node = wdContext.nodeNames();

IPrivateTableCompView.INamesElement elem=node.createNamesElement();

elem.setFname("1");

elem.setLname("1");

node.addElement(0,elem);

IPrivateTableCompView.INamesNode node1 = wdContext.nodeNames();

IPrivateTableCompView.INamesElement elem1=node1.createNamesElement();

elem1.setFname("5");

elem1.setLname("4");

node1.addElement(1,elem1);

IPrivateTableCompView.INamesNode node2 = wdContext.nodeNames();

IPrivateTableCompView.INamesElement elem2=node2.createNamesElement();

elem2.setFname("4");

elem2.setLname("4");

node2.addElement(2,elem2);

where Names is the node

Fname and Lname are the attributes under it.

Regards,

Satya.

Former Member
0 Kudos

Hi Sushma,

1) For adding the data to the table you can use the following code:


IPrivate<View Name>View.I<Node Name>Element element = wdContext.node<Node Name>().create<Node Name>Element();
		
element.set<Attribute Name>("Some String");
wdContext.node<Node Name>().addElement(element);

2) For adding the data to the dropdown by index you can use the following code:


IPrivate<View Name>View.I<Node Name>Element element = wdContext.node<Node Name>().create<Node Name>Element();
element.set<Attribute Name>("Some String");
wdContext.node<Node Name>().addElement(element);

Both the codes are same only the attribute name and the node name will change.

You will have to repeat the code number of times you want the values to be set.

I am afraid you can not show the dummy data without coding.

3) For check box you can have label and the Checked property of the checkbox as true or false: depending upon your requirement.

4) For CheckBoxGroup: You can create an Enumneration in the Simple type. Make the type of your attribute to that Simple type. In the Texts property of that CheckBoxGroup you can bind it with the attribute.

Hope it helps.

Regards.

Rajat

Former Member
0 Kudos

Hi Rajat,,

Thanks alot for ur help.

This will add one row in the table.

If i want this to add 10 rows in the table,,,,,,i written code but its not working out .

Please provide the code for that.

Please tell me how we can add image at the top right corner or bottom right corner of the page.

Regards

Sushma

Former Member
0 Kudos

Hi Armin

Without writing code in the implementation ,is it possible in the webdynpro properities to hardcode the values for table,dropdownlist,checkbox,checkbox group.The data must be displayed at the output of the table for view purpose.

How we can provide supply function to a node.Can u please provide the steps for that.

Thanks in advance

Regards

Sushma

Former Member
0 Kudos

No, you have to write (very simple) code for that.

In the IDE, define a supply function for the context node(s) that are used as the data source(s) of your UI elements.

Implement these supply functions like this (suppose the context node is on root-level, named "Items" and has attributes "name" (string) and "age" (integer)):


void supplyItems(IItemsNode node, IContextElement parentElement)
{
  for (int i = 0; i < DATA.length; ++i)
  {
    IItemsElement item = node.createAndAddItemsElement();
    item.setName(DATA<i>[0]);
    item.setAge(Integer.valueOf(DATA<i>[1]).intValue());
  }
}

//@@begin others

private static final String[][] DATA =
{
  {"Armin", "42"},
  {"Sophia", "9"},
  /* etc */
}

//@@end

Armin

Former Member
0 Kudos

Hi Sushma,

You can write code similar to following:

Here you have to create the element of the node which is to be displayed in table


IPrivate<View Name>View.I<Node Name>Element element = wdContext.node<Node Name>().create<Node Name>Element();
		
element.set<Attribute Name>("Some String");
wdContext.node<Node Name>().addElement(element);

Former Member
0 Kudos

Hi Sushma,

You will need to write code (can do so in wdDoInit() method) to fill the table with dummy values.

Create the context node instances & set the values for the attributes.

Now, bind these to the current context element (node which is provided in the 'datasource' of the table)

Kind Regards,

Nitin