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

javascript access to htmlb textEdit

Hi,

Since the htmlb object textEdit does not support javascript access through the jsObjectNeeded option I tried another approach.

This approach is mentioned several times on SDN but it does not perform as excepted.

<% String compID = null; %>


<hbj:textEdit 
id="reaction"
	text=""
	wrapping="SOFT"
	rows="5"
	cols="50">
	<%compID = myContext.getParamIdForComponent(reaction);%>
</hbj:textEdit>

<%=compID%>			(<-- test to write ID to html page)

This code retrieves the ID of the htmlb component. It works fine as I can write the htmlb ID to the html page.

However I need this ID in my javascript during a validation. The problem is that the ID is empty in the javascript.

Please help.

Raymond

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 24, 2008 at 09:34 AM

    Hi Raymond!

    Please post the javascript code in question. I remember doing the exact same thing a few years ago but have no access to the code anymore. Maybe I can patch something up by reviewing your code.

    Regards,

    J├╝rgen

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 24, 2008 at 09:34 AM

    Hi,

    You can set jsObjectNeeded to true and use textedit. Check these links.

    Javascript enabling and using JS methods on TextEdit component

    Useful undocumented javascript code for portal

    Regards,

    Harini S

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Harini,

      To my knowledge the textEdit object does not support jsObjectNeeded. When I try this I get a jsp error.

      Have you been able to use this property yourself?

      @ Juergen: The javascript is ok, the problem is that the jsp variable is null. So I have no htmlb id to use in javascript.

      Please let me know if you have a solution to read the HTMLB ID in javascript.

      Regards,

      Raymond

  • author's profile photo Former Member
    Former Member
    Posted on Jun 24, 2008 at 06:59 PM

    Hi,

    If nothing else works as a final solution you can do one thing. Define a java string txt="". Then assign the id of the text edit to this string txt and after this assign this as a value to a hidden input field which you will be able to access from javascript. Let me know if you have any issues with this.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 24, 2008 at 07:13 PM

    I guess u know the code to read the htmlb component in javascript..

    function test(){

    var funcName = htmlb_formid+"_getHtmlbElementId";

    func = window[funcName];

    var btnFld = eval(func("htmlb_btn_name"));

    var txt_value = btnFld.getValue();

    }

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Because we use Btexx EasyWCM (content management tool for SAP portal) we use embedded Iviews. This result in several HTMLB form ID's in the html page.

      If I use javascript: var funcName = htmlb_formid+"_getHtmlbElementId"; it seems to find the latest htmlb formid but not necessarily the correct formid.

      I used:

       
      var loDocForms = document.forms;
      for( var i=0; i<loDocForms.length; i++ )
      {
      	try
      	{
      		var funcName = loDocForms.id + "_getHtmlbElementId";
      		func = window[funcName];
      		var field = eval( func(id) );
      		
      		if(field)
      		{
      				return field;
      		}
      	}
      	catch( ex )
      	{
      	}
      }
      

      But this didnu2019t work either. Please let me know if there is a solution for this issue.

      Raymond

  • author's profile photo Former Member
    Former Member
    Posted on Jul 07, 2008 at 05:05 AM

    Hi Raymond,

    Try out the following piece of code (the code is tested and is working):

    <hbj:textEdit 	id="addComments" 
    			     wrapping="SOFT" 
    			     text="" 
    			     rows="2" 
    			    cols="100" > 
    						
    	<% addComments.setJsObjectNeeded(true); %>
    </hbj:textEdit>

    Then through javascript you can access the id of the text edit in the similar fashion.

    var txtAdCom= eval(func("addComments"));
    var value =txtAdCom.getValue();
    var length = txtAdCom.getValue().length;

    Please do reward with points if the solution is helpful.

    Thanks

    Ritushree

    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.