on 03-21-2008 10:57 AM
Hi ,
when i creating textview ui element dynamically
iam getting runtime exception following is the same.
*Note:_*_
*textForD=(IWDTextView)view.createElementIWDTextView.class,"test"+i);_*_
*_the above statement is the cause for this exception.
_*com.sap.tc.webdynpro.services.exceptions.CreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView
at com.sap.tc.webdynpro.progmodel.view.ViewElementFactory.createElement(ViewElementFactory.java:161)
at com.sap.tc.webdynpro.progmodel.view.View.createElement(View.java:177)
at com.cgsl.examples.dialogms.DispalyView.wdDoModifyView(DispalyView.java:153)
at com.cgsl.examples.dialogms.wdp.InternalDispalyView.wdDoModifyView(InternalDispalyView.java:294)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doModifyView(DelegatingView.java:78)
at com.sap.tc.webdynpro.progmodel.view.View.modifyView(View.java:337)
at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.doModifyView(ClientComponent.java:480)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doModifyView(WindowPhaseModel.java:551)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:148)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processPhaseLoop(WebDynproWindow.java:345)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:152)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:299)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:711)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:665)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:232)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:152)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(AccessController.java:215)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor54.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:44)
at java.lang.reflect.Constructor.newInstance(Constructor.java:315)
at com.sap.tc.webdynpro.progmodel.view.ViewElementFactory.createElement(ViewElementFactory.java:151)
... 34 more
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "Deasis0" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView
at com.sap.tc.webdynpro.progmodel.view.View.addElement(View.java:735)
at com.sap.tc.webdynpro.progmodel.view.ViewElement.<init>(ViewElement.java:40)
at com.sap.tc.webdynpro.progmodel.view.UIElement.<init>(UIElement.java:168)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView.<init>(TextView.java:82)
... 38 more
Thanks for your replys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh,
The exception came due to the use of element with duplicate ID:
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "Deasis0" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView
try this code:
IWDTransparentContainer containter = (IWDTransparentContainer)view.getElement( "RootUIElementContainer");
IWDLabel label;
for( int i = 0; i < 10; i++)
{
label = (IWDLabel)view.createElement( IWDLabel.class, "id" + i);
label.setText( "Text " + i);
containter.addChild( label);
}
This is to create 10 Labels dynamically; On changing with IWDTextView gives your result.
Regards
- Vinod
*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The stacktrace says it all.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The stacktrace says:
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "Deasis0" of type
This means, your code tries to add the TextView with ID "Deasis0" twice into a view. Can you post the complete code from wdDoModifyView()?
Armin
Hi Armin,
below is the code in doModifyView()
IPrivateDispalyView.ISelectTableDataElement element;
IWDTextView textForD;
IWDInputField input;
for(int i=0;i<wdContext.nodeSelectTableData().size();i++){
element=wdContext.nodeSelectTableData().getSelectTableDataElementAt(i);
if(element.getCheck()){
textForD=(IWDTextView)view.createElement(IWDTextView.class,"name"+i);
input=(IWDInputField)view.createElement(IWDInputField.class,"test");
textForD.setText(element.getDeasis());
IWDTransparentContainer container=(IWDTransparentContainer)view.getElement("RootUIElementContainer");
container.addChild(textForD);
container.addChild(input);
Do you want to recreate the complete view or just an area? In any case, you must ensure that the dynamic part is created and added only once to the view. This can be achived like this:
Add a boolean context attribute "recreate" to the context. In the button handler, set it to true. In wdDoModifyView(), do something like
wdDoModifyView(...)
{
if (wdContext.currentContextElement().getRecreate())
{
wdContext.currentContextElement().setRecreate(false);
IWDUIElementContainer dynamicArea = (IWDUIElementContainer) view.getElement("ID_of_area_to_recreate");
dynamicArea.destroyAllChildren();
/* add code that creates and add UI elements to dynamic area... */
}
}
Further you have to take care that you don't create UI elements with the same ID twice or try to add a UI element twice into a view.
Armin
Hi,
I think your code is not complete, I don't see any close bracket there.
anyway, inside of the loop you try to create InputField with the same name "test",
Please see "bold" for my correction.
if (firstTime){
IPrivateDispalyView.ISelectTableDataElement element;
IWDTextView textForD;
IWDInputField input;
for(int i=0;i<wdContext.nodeSelectTableData().size();i++){
element=wdContext.nodeSelectTableData().getSelectTableDataElementAt(i);
if(element.getCheck()){
textForD=(IWDTextView)view.createElement(IWDTextView.class,"name"+i);
input=(IWDInputField)view.createElement(IWDInputField.class,"test" + i );
textForD.setText(element.getDeasis());
IWDTransparentContainer container=(IWDTransparentContainer)view.getElement("RootUIElementContainer");
container.addChild(textForD);
container.addChild(input);
}
}
}
Hi Armin,
in your previous reply u said
Do you want to recreate the complete view or just an area? In any case, you must ensure that the dynamic part is created and added only once to the view.
yes,i have a requirement of dynamically add a ui element to the view each time an action triggers ie it may be one time or several times.
my requirement violating ur statement which i made bold and italic. is there any alternative to solve my problem ?
i would like to thank vinod and djln97 for reply.
regards,
ramesh
Hi Ramesh,
As i reply you before, you can find the part
textForD.setText(element.getDeasis());
And in the first post of yours, the exception specified that
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "Deasis0" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TextView
Its caused at creating the element object
IPrivateDispalyView.ISelectTableDataElement element;
element=wdContext.nodeSelectTableData().getSelectTableDataElementAt(i);
That has the intension to read data from the table UI element on check of the check button selection.
i think you should specify more part of code inorder to solve the problem; From the information given, we could solve only this much.
For creating UI controls dynamically, you can try my code that i posted before; For getting table details to get printed, we need more information from you.
Regards
- Vinod
*
Edited by: Vinod V on Mar 24, 2008 10:37 AM
Hi
if ur problem has solved make this question has solved
Thanks
Hazrath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
1)ucan create like below.
2)IWDTextView tex=(IWDTextView)view.createElement(IWDTextView.class,null);
3) tex.bindText("small text");;
Thanks
Hazrath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.