Skip to Content
author's profile photo Former Member
Former Member

Convert javascript var into a java String

Hi all,

I have an iview that receives an event. I tried to work with JSP this time. After I received the event I have a java-script var. I would like to put the content of the var into a htmlb-component:

<script>

EPCM.subscribeEvent( 'urn:com.test.EPCFExample', 'Event', getEvent);

function getEvent( evt ) {

var nameEvent = EPCM.loadClientData('urn:com.test.EPCFExample','textInput');

}

</script>

I have completly no clue what to do with the variable. Can this be transferred into a java-String? If I use it as value-parameter for an InputField it will be interpreted as a String ;-(

<hbj:inputField

id="eventField"

value=nameEvent

width="90"

visible="TRUE"

disabled="TRUE"

/>

Thanks for any help!

Martina

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jan 31, 2005 at 04:50 PM

    Hi Martina,

    to access HTMLB elements as JS HTMLB objects, the following function you should always wear in your pocket:

    function getHtmlbElement(pElementId) {
      var loDocForms = document.forms;
      for (var j = 0; j < loDocForms.length; j++) {
        try {
          var funcName = loDocForms[j].id + "_getHtmlbElementId";
          func = window[funcName]; 
          var element = eval(func(pElementId));
          if (element != null) {
            return element;
          }
        } catch(ex) {
      }
    }

    Setting "nameEvent" into the HTMLB tag cannot work because this is calculated at server side (it's JSP - Java).

    With the method given above, you retrieve the HTMLB JS object, here the HTMLB JS object InputField, when you write (and have set JSObjectNeeded to true):

    var myInpField = getHtmlbElement('eventField')

    On this object, you can set a value by

    myInpField.setValue(EPCM.loadClientData('urn:com.test.EPCFExample','textInput'))

    I didn't test it (the last combination), but it should work.

    A general question is if it is really needed to pass the data via ClientDataBag. Why not passing as a value of the event?

    Hope it helps

    Detlev

    PS: https://forums.sdn.sap.com/thread.jspa?threadID=26357 wasn't helpful? No reply, no points, nothing?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.