on 09-07-2005 10:07 PM
Hi,
I've been reading and looking for information about this topic but I couldn't find an example.
Basically I need to create Tabs dynamically (into a TabStrip) an embed (in each one) a new Interface View (of a Component Instance). This Component Instace is not the same every time, it depends on a runtime condition.
Thanks in advance.
Diego.
Hi Valery,
I was trying with your code example but I didn't arrive to a solution. I don't understand where to put each part of your code and how to complete it.
Basically my problem is: how to get an instance of a "component interface view" to embed in a
ViewContainerUIElement already created at design time.
I'll appreciate any response or example,
Best regards,
Diego.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Diego,
I plan to post a blog entry regarding this issue later this week. There are will be 3 use cases covered, your question seems to be the simplest one and it's alreay developed
You may mail me to vsilaev AT gmail DOT com and I'll sent you complete WD project as example
Here is an extract from this sample.
1. You have component SimpleContainer and component InnerA
2. SimpleContainer has component usage of InnerA (createOnDemand)
3. SimpleContainer has window SimpleContaineCW with embedded view SimpleContainerCV. View has ID assigned in window designer vuMain
4. SimpleContainerCV has exactly one ViewContainerElement with any name (for this sample it's enough -- this affects how view container assignment is found);
5. InnerA has window InnerACW and corresponding interface view InnerACWInterfaceView
6. The following code in wdDoInit of component controller of SimpleContainer does the trick:
public void wdDoInit()
{
/* Get window of itself (container) */
/* Window name is unqualified name of window (without package) */
final IWDWindowInfo myWindow = wdComponentAPI.getComponentInfo().findInWindows("SimpleContainerCW");
/* Find view inside own window (container) */
/* You have to assign id in WD window designer -- */
/* Embedd view, go to "Properties", set id (vuMain in this case) */
final IWDViewUsageInfo vuiMain = myWindow.getViewUsageByID("vuMain");
/* Get the very first view container assignment (vca) */
/* We know here it exists, sometimes it's necessary to create own dynamically */
/* Every vca may have several usages */
/* Only one is displayed, initially the "default" is diplayed */
final IWDViewContainerAssignmentInfo vcaiMainArea
= (IWDViewContainerAssignmentInfo)vuiMain.getViewContainerAssignments().iterator().next();
/* Create a (default) view usage for component usage interface */
final IWDViewUsageInfo vuiInner = vcaiMainArea.createEmbeddedViewUsage();
{
/* Setup view usage with component usage information */
final IWDComponentUsage cuInner = wdThis.wdGetInnerACUComponentUsage();
final IWDComponentUsageInfo cuiInner = cuInner.getComponentUsageInfo();
vuiInner.setComponentUsage( cuiInner );
/* Interface view name = unqualified_window_name + "InterfaceView"; */
vuiInner.setView( cuiInner.getUsedComponent().findInInterfaceViews("InnerACWInterfaceView") );
}
/* Mark view usage as default */
vcaiMainArea.setDefaultViewUsage( vuiInner );
}
Valery Silaev
EPAM Systems
Message was edited by: Valery Silaev
(added item regarding ViewContainerElement)
Ok, this is an update for the case when you have to create ViewContainerUIElement dynamically i.e. [4] "SimpleContainerCV has exactly one ViewContainerElement with any name" no longer valid.
So
1. In controller code comment out code:
final IWDViewContainerAssignmentInfo vcaiMainArea
= (IWDViewContainerAssignmentInfo)vuiMain
.getViewContainerAssignments()
.iterator()
.next();
2. Instead add the following code:
/* Create view container assignment */
final IWDViewContainerAssignmentInfo vcaiMainArea = vuiMain.createViewContainerAssignment();
{
final IWDViewInfo viMain
= (IWDViewInfo)vuiMain.getView();
final IWDViewContainerInfo vciViewContainer
= viMain.createViewContainer();
/* Transfer the name to view controller to setup UI element */
wdContext.currentContextElement()
.setViewContainerName( vciViewContainer.getName() );
vcaiMainArea.setViewContainer( vciViewContainer );
}
3. Map attribute "ViewContainerName" between view and component controllers (obviously, you have to create it in component controller)
4. Add the following code in wdDoMOdifyView:
if ( firstTime )
{
final IWDUIElementContainer group
= (IWDUIElementContainer)view.getElement( "grInner" );
group.destroyAllChildren();
final IWDViewContainerUIElement container
= (IWDViewContainerUIElement)view.createElement
(
IWDViewContainerUIElement.class, null
);
/* LINK UI CONTROL AND METAINFO */
container.setViewContainer
(
wdContext.currentContextElement()
.getViewContainerName()
);
group.addChild( container );
}
Valery Silaev
EPAM Systems
I'm having the same problem. How can I delete a componentUsage that I have created at runtime? The only interface I can access is the IWDComponentUsageInfo, but I need access to the IWDComponentUsage of the created componentUsage!
Thanks in advance,
Fabian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
this works perfectly, but how do I delete the component usage so that I can create a new component usage of the same type?
Thanks in advance,
Marion
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Valery,
It works perfectly. Thank you again.
Best Regards,
Diego.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
thanks a lot for your response, it was excellent. I was not at work last days so I could try it just today... and it works perfectly. One more thing about this topic:
I need to create de ViewContainerUIElement at runtime. Your example uses a ViewContainerUIElement created at design time. (Step 4. "SimpleContainerCV has exactly one ViewContainerElement with any name (for this sample it's enough -- this affects how view container assignment is found);")
Could you please explain me how to do it?
Best Regards,
Diego.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
Thanks a lot for your help. I'll try with Valery's solution.
Regards,
Diego.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
Once again, thanks a lot for that information. It surely does look complex :-). I hope we can expect a blog from you on this very soon. Valery, thanks for all those wonderful blogs & articles (It took me two whole days to decode your spell checker application and build a similar one. And since I didn't know anything about CMI classes, I had to import the jazzy project itself and use it directly)
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diego,
I feel that dynamic programming scenario can be done with the UI elements on a view ie putting an input
field on click of a button or enabling a table UI on click of any event.
But ur scenario of adding a view to Viewcontainer UI element I guess is not feasible.
Regards,
Guru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diego,
As far as I know, embedding of views into ViewContainer UI element is not possible at runtime.
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nibu,
This is possible, however it is very complex topic and deserves a tutorial on their own.
Here is my message where I explained how to dynamically arrange interface views of component usages in embeder view dynamically (warning: users reports about error with this code). Arranging views of same component even simpler and use same API.
Also important hint: view you are modifying should be invisible before modification!!! So we commonly create some Bootstrap empty view, link it via navigation to actual view with dynamic content, modify dynamic view in component controller and fire plug in wdDoInit of Bootstrap.
Valery Silaev
EPAM System
P.S. I can post another extract from my code, but I will not help with mysterious NPE you may encountered. Here only debugger helps
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
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.