cancel
Showing results for 
Search instead for 
Did you mean: 

Get label property

Former Member
0 Kudos

Hi @ all,

I have a label and this has a caption. If I wanted before that this caption is dynamic, I bound a context attribute to it. So I could change the value of this attribute to change the caption.

But is it possible to access to the caption of a label in the implementation part without binding a context attribute to it?

Kind Regards

Dennis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please make sure that you are passing the ID of the lable control to the .getElement() method.

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

I found out that I was using a textview, not a label. Now the code doesn't give back any exceptions.

Thank you all for the help.

Regards,

Dennis

Former Member
0 Kudos

Hi,

thank you all for the help.

I tried to use the code you give me, but on thje line:

IWDLabel lbl=(IWDLabel)view.getElement("label");

I got an error stacktrace:

Error stacktrace:

java.lang.ClassCastException

at com.csc.ar.MainView.wdDoModifyView(MainView.java:137)

at com.csc.ar.wdp.InternalMainView.wdDoModifyView(InternalMainView.java:166)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doModifyView(DelegatingView.java:78)

at com.sap.tc.webdynpro.progmodel.view.View.modifyView(View.java:190)

at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.doModifyView(ClientComponent.java:397)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.modifyView(ClientApplication.java:613)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:372)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:640)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)

at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:48)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:391)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:265)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)

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:37)

at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)

What does it mean?

Thanks,

Dennis

Former Member
0 Kudos

Hi Dennis,

You can do it through the implementation by using the following code.


    //Get the label object
    IWDLabel label = (IWDLabel)view.getElement("label");

    //Set the text of the label object
    label.setText("<<Some text>>");

    //Get the text of the label object
    String strCaption = label.getText();

You have to write the code in the "wdDoModifyView()".

Setting and getting the property of a UI element is advised to do using the context variables.

Regards,

Santhosh.C

Former Member
0 Kudos

If you talk about IWDLabel, then IWDLabel.getText() gives you the text. This holds for the bound and unbound case.

Armin

Former Member
0 Kudos

Hi,

Try this in "wdDoModifyView" method

IWDLabel lbl=(IWDLabel)view.getElement("<<Label ID>>");

lbl.getText();

Regards, Anilkumar