cancel
Showing results for 
Search instead for 
Did you mean: 

Runtime Exception while creating dynamic ui

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks for your replys.

Former Member
0 Kudos

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

*

Former Member
0 Kudos

The stacktrace says it all.

Armin

Former Member
0 Kudos

hi armin,

1. when i used the same code in one example it working fine?

2.but in another application it giving the above exception?

let me know any solution for it?

thanks,

ramesh

Former Member
0 Kudos

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

Former Member
0 Kudos

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);

Former Member
0 Kudos

How often is this code executed? Is it in a if (firstTime) or some other conditional block?

Can you please post the complete code of wdDoModifyView()?

Armin

Former Member
0 Kudos

Hi armin,

when i select some button in dialog box,i want to create new ui elements in view and close the dialogbox.

iam following the basic dialogbox example available in sdn pdfs.

so please guide me how to do it?

Former Member
0 Kudos

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

Former Member
0 Kudos

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);

}

}

}

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Just read my posting again and use the shown technique. Before creating and adding view elements again to the view, the old ones have to be destroyed first. The boolean flag that controls this has to be set to true in the action handler. That's all.

Armin

Former Member
0 Kudos

Hi

if ur problem has solved make this question has solved

Thanks

Hazrath

Former Member
0 Kudos

Hi Hazrath,

i tried with ur code ,but iam getting the following Exception.

com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DispalyView): unknown child node ssss

Regards,

ramesh

Former Member
0 Kudos

Hi

1)ucan create like below.

2)IWDTextView tex=(IWDTextView)view.createElement(IWDTextView.class,null);

3) tex.bindText("small text");;

Thanks

Hazrath