on 01-31-2007 4:11 PM
Hi,
I've build a basket component. I've used this component on 2 different tabs...which means i have to create 2 different instances. As you might suspect, the things in the basket are allways the same...so the basket components have to be synchronized. Is this possible?
You might also think that its much handier to have just 1 basket component....but they want to have 2 tabs which contain both the basket so i cannot re-use the view because this is a singleton.
anyone have any ideas?
much thanks,
Hugo Hendriks
Hugo,
Below is just theory, but anyway...
1. In inner component create 2 winbows
2. In outer component create single ComponentUsage of inner component
3. In outer component embed different windows of inner component on different tabs.
While usage is the same, data will be always synchronized. Oh, inner component views must use mapped context node. I mean, nodes mapped to context of component controller.
If this doesn't work, then do reverse context mapping:
1. In interface controller of inner component create node(s) with isInputElement set to true
2. In inner component views must be mapped to the nodes created in [1]
3. In outer component create 2 usages of inner component
4. In outer component create context nodes that holds data
5. Map context of component usage to node from [4] of outer component
While there is only one actual context node (in outer component) then there is always single source of truth and both component usages will stay in sync via mapping.
Valery Silaev
SaM Solutions
http:/www.sam-solutions.net
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Valery,
your first approach of showing one single component instance in two different flavors by embedding separate component interface views/windows of it is very interesting. The advantage would be to define only one component usage.
But the problem of this approach is, that it only works for <b>disjoint view compositions</b> defined in window A and window B (comp interface views A and B) of this visual component. As soon as the same view instance is visible within window A and window B at the same time the Web Dynpro Runtime throws an exception.
Therefore your second alternative based on two component usages and external context mapping is the only feasible one.
Best regards, Bertram
Hi Valery,
Im a bit confused at step 4 and 5 of your sollution.....Im quite new to inter-component context mapping....
<b>4. In outer component create context nodes that holds data</b>
Does this mean create the nodes in the outer controller view that contains both component-usages?
<b>5. Map context of component usage to node from [4] of outer component</b>
How do i map the context of the usage to the just created nodes in the outer controller view?
Much thanks,
Hugo
Hugo,
<i>4. In outer component create context nodes that holds data
Does this mean create the nodes in the outer controller view that contains both component-usages?</i>
You must create this node in <b>component controller</b> of outer component
<i>5. Map context of component usage to node from [4] of outer component
How do i map the context of the usage to the just created nodes in the outer controller view?</i>
In outer component structure tree expand node with usage and double-click on usage (or usage interface) node. WD should open dialog with usage properties / mapping. Add outer component as required controller to usage then on mapping tab perform mapping.
Valery Silaev
SaM Solutions
oops, ok, stil have 2 more questions if thats ok?
In the inner component I have a downloadFile UI element. In the context of the view a downloadUrl which is a binary neccesary for the UIelement.
First question is that i cant set this attribute to isInputElement = true because its under the root. To fix this, do i just create a node and in the wdInit or do I have to something else because now i cannot map it?
Second question is that in the wdDoModify i have some code also for the downloadFile UI element to set the mime type:
// get attribute info for context attribute 'FileResource'
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateBasketCompView.IContextElement.DOWNLOAD_URL);
// create a modifiable binary type for the context attribute
// which stores the MIME-object.
IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
binaryType.setMimeType(WDWebResourceType.UNKNOWN);
//create date/time stamp to incorporate into the name of the zip
DateFormat dateFormatter = new SimpleDateFormat("ddMMyyyyHHmm");
String fileName = "TPD-" + dateFormatter.format(Calendar.getInstance().getTime())+".zip";
binaryType.setFileName(fileName);
but when i leave this code, i get an exception saying:must not modify the datatype of a mapped attribute
How do i solve this?
Thanks & regards,
Hugo
Hugo,
As with any mapping you may modify only original node but not mapped ones.
In your case (reverse context mapping) original node is one declared in outer component, and mapped are in inner component.
So just move your code that modifies simple type from inner to outer component.
Valery Silaev
SaM Solutions
Hi Valery,
thanks for that...seems that it works now.
regards,
Hugo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DownloadFile UI Element mapping errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Hugo,
toplevel context attributes cannot be mapped externally. Read my last comment on this restriction within the SAP Online Help: http://help.sap.com/saphelp_nw2004s/helpdata/en/66/a5384162316532e10000000a1550b0/frameset.htm.
<i>Note that context attributes cannot be defined as can be mapped externally later directly below the root node (top level context attribute) in the component interface content. External context mapping is possible only for those context attributes that belong to independent or dependent context nodes.</i>
Define an independent context node with cardinaltiy 1..1 instead and add the attribute there.
Regards, Bertram
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.