on 04-18-2009 7:41 AM
Hi All,
I had created a dynamic node ("demo") and added two attributes ("appid" & "apptext") to it. And also i created three elements for that node and binded the values. Now my dynamic node is having 3 records. I am creating link to action dynamically and binded a action called "onClick". Now in the output i am getting
linktoaction1
linktoaction2
linktoaction3
Now i am stuck with, when i am clicking either of these 3 linktoactions in runtime, i am able to get only the first record. May i know how to traverse through the node. i.e on clicking of linktoaction2 i want to fetch second records of the node and simillarly and linktoaction1 and linktoaction2. I used the following code in "onClick"
IWDNode dynnode = wdContext.currentContextElement().node().getChildNode ("demo",IWDNode.LEAD_SELECTION);
IWDNodeElement ele = dynnode.getCurrentElement();
String text = (String)ele.getAttributeValue("Apptext");
wdComponentAPI.getMessageManager().reportSuccess(text);
Thanks,
Mugundhan.
If only one method is being used 'onClick' for all three LinkToAction UI elements, parameter mapping is a good option.
in wdModifyView()
IWDLinkToAction action1 = (IWDLinkToAction) view.getElement("linktoaction1");
action1.mappingOfOnAction().addParameterMapping("0", "index");
add parameter to the method 'onClick'
name: index
type: string
change the code
IWDNode dynnode = wdContext.currentContextElement().node().getChildNode ("demo", Integer.parseInt( index));
[Dynamic Programing - Documentation|http://help.sap.com/saphelp_nw04/helpdata/en/0a/86a74052033713e10000000a155106/content.htm]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nikil,
Ya i had assigned only one action for the three linktoactions. I am filling my dynamic node according to the number of records coming from the RFC. How can i pass the index value (i.e) how to identify that which action is being clicked. I am little confused. Thia is what i wrote in my coding,
In Init method,
IWDNodeInfo nodeInfo=wdContext.getNodeInfo().addChild("demo", null,true,true,
true,false,false,true,null,null,null);
nodeInfo.addAttribute("Applid", "com.sap.dictionary.string");
nodeInfo.addAttribute("Apptext", "com.sap.dictionary.string");
IWDNode node = wdContext.wdGetAPI().getRootNode().getChildNode("demo",IWDNode.NO_SELECTION);
for(int i=0; i<wdContext.nodeEt_Mobileportal().size();i++)
{
IWDNodeElement nodeElem = node.createElement();
nodeElem.setAttributeValue("Applid", wdContext.nodeEt_data().getEt_dataElementAt(i).getApplid());
nodeElem.setAttributeValue("Apptext", wdContext.nodeEt_data().getEt_dataElementAt(i).getApptext());
node.addElement(nodeElem);
}
In domodify method,
if(firstTime)
{
IWDTransparentContainer cont= (IWDTransparentContainer)view.getElement("menu");
for( int i=0; i<wdContext.nodeEt_Mobileportal().size(); i++)
{
IWDLinkToAction link = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,"link"+i);
link.setText(wdContext.nodeEt_Mobileportal().getEt_MobileportalElementAt(i).getApptext());
link.setOnAction(wdThis.wdGetGotoappAction());
cont.addChild(link);
}
}
Thanks,
Mugundhan
Question: Is it really need to use programmatic context creation here? Why not just use a RowRepeater?
To your question: To assign each link to some node element you can use a parameter mapping like
wdDoModifyView(...)
{
for ( int i = 0; i < size of "demo" node; ++i )
IWDLinkToAction link = ...;
link.mappingOfOnAction().addParameter("index", i);
}
onLinkClickedAction(..., int index)
{
IDemoElement e = wdContext.nodeDemo().getDemoElementAt(i);
}
But please answer also my question.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Armin,
Yes, I am going to fetch the data from the RFC. The data will be delivered according to the role we created for a user. So for every user the number of records and data will vary. So i had decided to go for dynamic context creation. May i know what is a row repeater?
Thanks,
Mugundhan
With a RowRepeater UI element (available since version 7.1, not sure about 7.0) you could avoid the programmatical creation of the links . (In earlier versions just use a Table with LinkToAction cell editor).
Assuming a context node
Rows (node, c=0:n)
+ text (string)
you would put the following elements at designtime into your view:
RowRepeater: dataSource = "Rows"
+ LinkToAction (RowElement), "text" -> "Rows.text", onAction -> "LinkClicked", onAction.nodeElement -> "row"
Action "LinkClicked" would have a parameter "row" of type IRowsElement. The action handler would be
void onLinkClickedAction(..., IRowsElement row)
{
/* row is the node element representing the row of the clicked link */
}
Armin
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.