on 04-09-2008 9:50 AM
Hi All,
I am creating dynamic mapping of context between comp controller and view part by using the following link.
-creating only one node and one attribute say "attr1" which has value "hi" dynamically.
-mapping dynamically to view.
The problem is I can able to print the value attribute "attr1" which is mapped from comp controller to view. But unable to print the value "hi" which is set in attr1.
Com Controller Code:
IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("dynamicNode1",null,true,true,false,false,false,true,null,null,null);
nodeInfo.addAttribute("attr1","com.sap.dictionary.string");
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("dynamicNode1",IWDNode.LEAD_SELECTION);
IWDNodeElement nodeElem = node.createElement();
nodeElem.setAttributeValue("attr1","hi");
node.addElement(nodeElem);
If i bind this attrinfo to an UI element, I can see the output "hi".
But I dont want to create an UI element. Just want to display the value from that attribute which is mapped from comp controller to view dynamically.
View Code:
IWDNodeInfo compNodeInfo = wdThis.wdGetExportexSampleCompController().wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode1",IWDNode.LEAD_SELECTION).getNodeInfo();
IWDNodeInfo localNodeInfo1 = wdThis.wdGetAPI().getContext().getRootNodeInfo().addMappedChild("dynamicNode2",null,true,false,false,null,false,true);
localNodeInfo1.setMapping(compNodeInfo,true);
localNodeInfo1.addAttributesFromDataNode();
Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();
while(itr.hasNext()){
IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();
msgMgr.reportSuccess(attrInfo.getName() + "attrname");
In the above code, attrInfo.getName()-gives the name of the value attribute. "attr1"
Similarly I need to display the value of that attribute.
Hope I have clearly explained my problem. Please suggest some logic but not the links.
Regards,
Subashini.
Hi Ayyapparaj,
Thanks for replying instantly. attrInfo is an object for interator.
Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();
while(itr.hasNext()){
IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();
msgMgr.reportSuccess(attrInfo.getName() + "attrname");
}
So where should I replace with your code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Iterator itr = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getNodeInfo().iterateAttributes();
while(itr.hasNext()){
IWDAttributeInfo attrInfo = (IWDAttributeInfo)itr.next();
String str = wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getElementAt(0).getAttributeValue(attrInfo.getName())
msgMgr.reportSuccess(attrInfo.getName() + "attrname");
msgMgr.reportSuccess(str);
}
Regards
Ayyapparaj
IWDNode node = wdContext.getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION);
IWDNodeElement element = node.getElementAt(0); /* assume it exists */
for (Iterator attributes = node.getNodeInfo().iterateAttributes(); attributes.hasNext(); )
{
IWDAttributeInfo attribute = (IWDAttributeInfo) attributes.next();
Object value = element.getAttributeValue(attribute.getName());
}
Armin
Hi Ayyapparaj&Armin,
Thanks for your instant replies and clarified my doubts.
Awarded points.
Thanks a lot.
Regards,
subashini.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yeah, view to view mapping is not possible. How about view1 to controller then to view2?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Armin&Ayyapparaj,
Thanks for your replies. I have got one more query.
Is it possible to create an attribute dynamically in one view and get it in another view?
Example:
I have 2 views say v1 and v2.
I am creating dynamic attribute&setting its value in v1 - attr1,"hi".
I want to get this attribute attr1 and its value "hi" in v2 through dynamic mapping. Please note that everything is dynamic(node creation,attr creating,mapping).
Is this possible?
Hope I am clear with the query.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
use
Assuming 1 element is existing, other wise it will result in nullpointer exception
wdThis.wdGetAPI().getContext().getRootNode().getChildNode("dynamicNode2",IWDNode.LEAD_SELECTION).getElementAt(0).getAttributeValue(attrInfo.getName())
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.