on 05-23-2007 7:35 AM
Hello
I am generating TextEdit UIs dynamically.
I am having a table with data in the same view.
Now I want to fill the data from the table in those TextEdit UIs.
What I am doing:
My table is having two columns.
Now I make the UIs as the size of the table.
Suppose 2 is the answer.
Here AA conatins the data
context-->
node A
attribute b
attribute c
node AA
attribute v1
attribute v2
node AA contains the data
Now in wdDoModifyView-->
if(firstTime)
{
int s = wdContext.nodeAA().size();
for(int i=0;i<s;i++)
{
IPrivateKkView.IAAElement aa = wdContext.nodeAA().getAAElementAt(i);
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
IWDAttributeInfo attrInfo = wdContext.getChildNode("A",0).getNodeInfo().getAttribute("b");
IWDTextEdit ed = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit_1"+i);
ed1.bindValue(attrInfo);
IWDAttributeInfo attrInfo1 = wdContext.getChildNode("A",0).getNodeInfo().getAttribute("c");
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2"+i);
ed1.bindValue(attrInfo1);
tCont.addChild(ed);
tCont.addChild(ed1);
tCont.createLayout(IWDMatrixLayout.class);
}
}
Now what I want is that whatever there is in node AA should populate in the Dynamic created TextEditBox.
Whenever I am trying to bind the value of the TextEdit UIs to the attribute of node AA , error comes.
Can any one help me in that.
Thanks in advance.
Hi,
Try the below code
IWDNodeInfo node = wdContext.getNodeInfo();
int s = wdContext.nodeAA().size();;
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
for(int i=0;i<s;i++)
{
node.addAttribute("context_1"+i,"com.sap.dictionary.string");
String strA = wdContext.nodeAA.get NodeAAelement(i).geta();;
IWDTextEdit ed = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit_1"+i);
wdContext.currentContextElement().setAttributeValue("context_1"+i,strA);
ed.bindValue("context_1"+i);
node.addAttribute("context_2"+i,"com.sap.dictionary.string");
String strB = wdContext.nodeAA.get NodeAAelement(i).getb();
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2"+i);
wdContext.currentContextElement().setAttributeValue("context_2"+i,strB);
ed1.bindValue("context_2"+i);
tCont.addChild(ed);
tCont.addChild(ed1);
tCont.createLayout(IWDMatrixLayout.class);
}
AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Annop
The probelm is solved, please check the points.
I appreciate other members who took their time in suggesting the solution.
Thanks Everyone
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
use this code in wddoModify View()
if(firstTime)
{
int s = wdContext.nodeAA().size();
for(int i=0;i<s;i++)
{
IPrivateKkView.IAAElement aa = wdContext.nodeAA().getAAElementAt(i);
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
IWDAttributeInfo attrInfo = wdContext.getChildNode("AA",0).getNodeInfo().getAttribute("v1");
IWDTextEdit ed = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit_1"+i);
ed.bindValue(attrInfo);
IWDAttributeInfo attrInfo1 = wdContext.getChildNode("AA",0).getNodeInfo().getAttribute("v2");
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2"+i);
ed1.bindValue(attrInfo1);
tCont.addChild(ed);
tCont.addChild(ed1);
tCont.createLayout(IWDMatrixLayout.class);
}
}
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi context-->
node A
attribute b
attribute c
Here Node A is not dynamically created i guess
int s = wdContext.nodeAA().size();
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
for(int i=0;i<s;i++)
{
String strA = wdContext.nodeAA.get NodeAAelement(i).geta();
IWDTextEdit ed = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit_1"+i);
ed.setValue(strA);
String strB = wdContext.nodeAA.get NodeAAelement(i).getb();
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2"+i);
ed1.setValue(strB);
tCont.addChild(ed);
tCont.addChild(ed1);
tCont.createLayout(IWDMatrixLayout.class);
}
AM
Message was edited by:
Anoop Mathew
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can directly map the context of the table attirbutes to the TextEdits while dynamiaclly creating the UI's.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<b>Could you please state the purpose of having UI's equal to the size of the table.</b>
If the purpose is to allow the user to cahnge the values
then you can have only
two TextEdit's and ask the user to choose the table row he likes to update.once the user selects the row
the values can be displayed in the TextEdit's and changed.The changed values can then be updated back
to the table.
Hi,
U would have binded the textEdit with the attribute.
Case1: if binded with the attribute created in the context. the set like this.
wdContext.currentContextElement().set<attribute name in context>(<get the value from table>).
Case2: if binded dynamically.
IWDAttributeInfo a1=wdContext.getNodeInfo().addAttribute("textatt","ddic:com.sap.String");
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2");
ed1.bindValue(textatt);
Then set the value
wdContext.currentContextElement().setAttributeValue("textatt",<Value from table>));
Regards,
Vijai
Hello Shriram
The reason for the same number of UIs(TextEdit) equal to the size of the tabel is somthing like this:
In the wdDoInit()--> I am populating the table with some data.
Now I want to display the same number of records from the table to the UIs
i.e. if there are 2 records in table, I want to display 2 TextEdit UIs dynamically (leave the number of attributes in the table at this time)
So I am creating those UIs in the wdDoModifyView().
But the thing is that I am not able to display the records from the table to the UIs.
Like initially there were 2 records in the table so there must be 2 UIs showing the record from the table.
I am not able to bind the vale to that UI so that they can show the record.
The readOnly property is set to true so that no one can edit it.
These UIs just showing the record in the table.
Hope now the problem is clear.
Hi ,
Could you explain the business requirement behind these scenario.
Depending on the number of records in your table , you need to display the same table data in TextEdit.. ?
In this scenario, you would not be able to use the same attributes in the node to display the data in TextEdits.
So you need to create duplicate node(of the same structure ) of cardinality 1..1 and bind them to the textedit UI.
Repeat this for every record.. And every time some one changes it , you need to synchronize it between the main nodes and these duplicates..
Here resync of data is not mentioned.. Create structure as u r table node structure.. so that u can re-use while creation of child nodes..
if(firstTime)
{
for(int i = 0;i<wdContext.nodeTableData().size();i++)
{
IWDNodeInfo currentDuplicateNode = wdContext.getNodeInfo().addChild("<nodename>"+i,null,true,true,false,true,false,true,"<packagename>.<structure name>",null,null);
//create as many of these elements as columns
//first attribute in the record
IWDTextEdit text1= (IWDTextEdit)view.createElement(IWDTextEdit.class,null);
text1.bindValue("<Nodename>"+i+".attributename1");
wdContext.getChildNode("<nodename>"+i,0).getCurrentElement().setAttributeValue("attributename1",wdContext.node<Base table node>().get<base table node >ElementAt(i).get<attributename1>());
//add this to some container..
tc.addChild(text1);
//second attribute in the record
IWDTextEdit text2= (IWDTextEdit)view.createElement(IWDTextEdit.class,null);
wdContext.getChildNode("<nodename>"+i,0).getCurrentElement().setAttributeValue("attributename2",wdContext.node<Base table node>().get<base table node >ElementAt(i).get<attributename2>());
text2.bindValue("<Nodename>"+i+".attributename2");
//add this to container..
tc.addChild(text2);
}
}
Regards
Bharathwaj
Message was edited by:
Bharathwaj
Hi,
If your requirement is just to show the table records then you can use TextView instead of TextEdit.
In TextView you dont have issue of attribute binding.
You have to just sset the value of the Text property of TextView.
if(firstTime)
{
int s = wdContext.nodeAA().size();
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
tCont.createLayout(IWDMatrixLayout.class);
for(int i=0;i<s;i++)
{
IPrivateKkView.IAAElement aa = wdContext.nodeAA().getAAElementAt(i);
IWDTextView ed1 = (IWDTextView)view.createElement(IWDTextView.class, "TextView_1"+i);
ed1.setDesign(WDTextDesignView.<Choose your design>);
ed1.setText(aa.getfirstColumnValue()"\n"aa.getsecondColumnValue and so on.);
tCont.addChild(ed1);
}
}
Hi,
If you still feel like using TextEdit then heres the code
if(firstTime)
{
int s = wdContext.nodeAA().size();
IWDTransparentContainer tCont = (IWDTransparentContainer)view.getRootElement();
tCont.createLayout(IWDMatrixLayout.class);
for(int i=0;i<s;i++)
{
IPrivateKkView.IAAElement aa = wdContext.nodeAA().getAAElementAt(i);
IWDAttributeInfo attrInfo = wdContext.nodeA.getNodeInfo().getAttribute("b");
IWDTextEdit ed = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit_1"+i);
ed.bindValue(attrInfo);
ed.setValue(aa.getfirstColumnValue());
IWDAttributeInfo attrInfo1 = wdContext.nodeA.getNodeInfo().getAttribute("c");
IWDTextEdit ed1 = (IWDTextEdit)view.createElement(IWDTextEdit.class,"TextEdit_2"+i);
ed1.bindValue(attrInfo1);
ed1.setValue(aa.getSecondColumnValue());
tCont.addChild(ed);
tCont.addChild(ed1);
}
}
Hi Vivek,
Can u please tell,what's the error u r getting?
regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.