Access HTMLB controll in Javascript

Hi,
I am tring to access an HTMLB controll (InputField) from JavaScript, but having some problems...
I have created a DynPage and created an InputField: InputField inField = new InputField("inField");
Now, in the javascripts I am trying to access this InputField text with:
var txt = document.form.inField.value
but it does not work... I get a JavaScript error.
Any suggestion how to access the InputField from the JS? maybe with getElementByid?
Thanks in advance,
Aviad

Hi Aviad,
    Htmlb controls are not a direct reprsentation of html controls. The way to get hold of them is by following lines.
function validateField()
//htmlb_formid : this is automatically generated
//the following lines will get you the javascript function
//name to call to get hold of your input field
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
//The funtion is called with id of the input field
//which returns the htmlb control object
var inputfield = eval(func("fname_input"));
//this will get you the value of inputfield
var inputString = inputfield.getValue().toString();
<b>Note: Make sure you set jsObjectNeeded = true for the htmlb control.</b>
PS: Please consider rewarding points for helpful answer. thank you.
Message was edited by: Prakash  Singh

Similar Messages

  • Usage of htmlb controls  in javascript

    hi,
    Could anybody give links regarding the usage of htmlb controls in javascript?

    Hi Ganesh,
    here comes some official documentation: http://help.sap.com/saphelp_nw04/helpdata/en/43/067941a51a1a09e10000000a155106/frameset.htm
    Also see these threads on SDN: HTMLB-Javascript and Access HTMLB controll in Javascript
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • Proplem: Access HTMLB controls from java code

    Hi,
    I am new to iView development for EP6. So my problem should be easy to solve (for you ).
    I created in the NW Dev Studio a JSP DynPage.
    The following files were created or edited:
    1.     JSP file (created)
    2.     java file (created)
    3.     portalapp.xml (edited)
    In order to make the page running (proccessing) I changed the following things:
    1.     JSP file – Add taglib reference to HTMLB-class
    2.     portalapp.xml – Remove the „native“ property so the JSP file will not be accessed directly.
    Now I want to do the following:
    On the JSP page I placed severeal HTMLB controls (textViews).
    From the java code I try to access these controls in the „doProcessBeforeOutput“ method and change/set values.
    But I get all the time a null-Exception.
    Code (JSP)
    <%-- mcmsprovider.jsp --%>
    <%@ taglib uri= "tagLib" prefix="hbj" %>
    <hbj:content id="cntMcmsProvider" >
      <hbj:page title="MCMS Provider Dynpage">
       <hbj:form id="frmMcmsProvider" >
                 <hbj:textView id="tvwScript" encode="false"></hbj:textView>
                 <hbj:textView id="tvwStyle" encode="false"></hbj:textView>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    Code (JAVA):
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
           TextView tvw = (TextView) this.getComponentByName("tvwStyle");
           tvw.setText("Here the dynamic text");
    I also tried to add raw text to the form but also null excpetion:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
           Form frmCurrent = (Form) this.getForm();
           frmCurrent.addRawText("<h3>This comes from here</h3>");
    My goal is to dynamically add controls to the form, but until now I think it will be a dream:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
      Form form = (Form)this.getForm();
           TextView tvw  = new TextView("tvwDynamic");
           tvw.setText("Here the dynamic control");
           form.addComponent(tvw);
    The normal page processing runs:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
    Any help is greatly appreciated.

    Eike
    Here is the example straight from the PDK documentation. This should help you a little
    UsingAbstractPortalComponentWithHTMLB.java
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.DataType;
    import com.sapportals.htmlb.enum.GroupDesign;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class UsingAbstractPortalComponentWithHTMLB extends AbstractPortalComponent {
        //Fill in your output for "normal" content creation mode here
        protected void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
            IPageContext myContext = PageContextFactory.createPageContext(request, response);
            if (myContext == null) {
                System.out.println("htmlb service did not start up as expected.");
            Form myForm = myContext.createFormDocument("First Experiment");
            Event lastEvent = myContext.getCurrentEvent();
            Group myGroup = new Group();
            myGroup.setWidth("350");
            myGroup.setTitle("First Experiment");
            myGroup.setDesign(GroupDesign.SAPCOLOR);
            myForm.addComponent(myGroup);
            GridLayout gl = new GridLayout();
            myGroup.addComponent(gl);
            if ((lastEvent != null) && (lastEvent.getComponentName().equals("submit"))) {
                String name = myContext.getDataForComponentId("USER_NAME").toString();
                TextView label = new TextView("Hi, " + name);
                gl.addComponent(1, 1, label);
                Button myButton = new Button("goback", "Go back");
                myButton.setOnClick("goBack"); // ignored anyway
                gl.addComponent(2, 1, myButton);
            } else {
                TextView label = new TextView("What's your name?");
                gl.addComponent(1, 1, label);
                InputField inf = new InputField("USER_NAME");
                inf.setType(DataType.STRING);
                gl.addComponent(1, 2, inf);
                Button myButton = new Button("submit", "Tell");
                myButton.setOnClick("submit");
                gl.addComponent(2, 2, myButton);
            myContext.render();

  • Accessing HTMLB checkbox in javascript

    Hi,
    I have the following scenario:
    1) jsp "main.jsp" has a checkbox with id="chkBoxId"
    2) In this "main.jsp" at the end, there is a jsp include
       including another jsp "buttons.jsp" - which contains a
       SUBMIT button.
    3) On this SUBMIT button, I am calling a javascript
       function "check()" in the "onClientClick" attribute.
    4) In this "check()" function I want to access the
       checkBox (present in "main.jsp")
    Now when I try doing this using the following code in the check() function, it gives me a "Undefined is null or not an object".
    function check(chkBoxId) {
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    var chkBox1 = eval(func(chkBoxId));
    // The checkbox is obtained
    if (chkBox1)
      alert("Not Checked");
    Plzz help me !!!
    regards,
    Jitendra

    HI,
    U can write the javascript function in the header tag or create a .js file in which u write the javascript code.
    the javascript code can be like
    function ValidateForm()
    if(document.form1.s_material.value=="")
    alert("enter material");
    return false;
    return true;
    where form1 is id of form and s_material is iD of input field.
    In your coding for button onClientClick like :
    <htmlb:button  id="s_but_submit"
                                       width="20"
                                       onClick="submit"
                                       onClientClick="if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"
    Regards,
    Siddhartha

  • Accessing HTMLB from javascript

    Hi expert,
    Can someone explain how to access the attributes,methods avialable in javascript to access htmlb objects in a page,
    Like for e.g.,
    htmlbSL(this,2,'SUBMITVALUES:HandleSubmit')
    Is there any document available?
    Thank you
    AP

    Hi AP,
    I believe there is no documentation avaliable about this.
    Maybe because this accessing method is not right to do
    but I can explaint about the function htmlbSL
    function htmlbEL(this,2,'SUBMITVALUES:HandleSubmit');
    this                      = HTML element.
    2                         = event type index.
    SUBMITVALUES:HandleSubmit = objectID:eventName
    if you want to know list of event type index.
    here the list:
    <b>EVENT TYPE                  INDEX</b>
    'htmlb:breadCrumb:click'      1
    <b>'htmlb:button:click'          2</b>
    'htmlb:checkbox:click'        3
    'htmlb:image:click'           4
    'htmlb:link:click'            5
    'htmlb:radioButton:click'     6
    'htmlb:tabStrip:click'        7
    'htmlb:tree:click'            8
    hope this can help you.
    respeck,
    -adyt-

  • Accessing HTMLB Visible controls in Jspdynpage

    Hi
    I am new to portals, presently i am doing portal application with jspdynpage.Can anyone provide me sample application
    using HTMLB Visible controls(checkbox,radiobutton etc) and to access that controls in jspdynpage.

    Hi lalithavani,
    You can find the tutorials for PDK on help.sap.com On the left side navigation, under SAP Netweaver -> SAP netweaver 2004 -> english -> People Integration-> Portal-> Portal Developer Guide. In that you have sections Go and Create and Core Development Tasks* In that you have all the information given about PDK.
    you can access the same using the following link
    http://help.sap.com/saphelp_nw04/helpdata/en/a9/76bd3b57743b09e10000000a11402f/frameset.htm
    For information about the UI elements and the usage you can access the following link
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/01f34026d70b06e10000000a155106/frameset.htm
    For JSP Dyn pages:https://www.avispublics.com/irj/portalapps/com.sap.portal.pdk.htmlb.htmlbmanuals/docs/dynpage-01.html
    In that you have sections which explains about the layouts, layout controls, visible controls(the UI elements which will be visible) and nonvisible controls(like bookmarks and timers). this sections provides both with the tablib usage and class lib usage and the code snippets are also given.
    If you have java developer role in your portal then under PDK starter & Viewer you can find all the examples given for the UI elements.
    there you can find codes also.
    provide your mailid so that i can send you some sample applications
    Hope this helps.
    regards,
    mrudula
    reward points if helpful
    Edited by: Mrudula Jarugula on Feb 21, 2008 3:36 PM
    Edited by: Mrudula Jarugula on Feb 21, 2008 3:37 PM

  • HTMLB control for displaying clientside error messages

    Hi all,
    I want to display client side validation error messages in a JSP DynPage.I have tried MessageBar but it can't be accessed from JavaScript file.Becuase of that i couldn't write error messages from .js file using MessageBar.Can U plz tell me is there any other HTMLB control or other way to display clientside error messages.
    Urgent
    Thanks
    Sampath.G

    Hi Sampath,
    I have an idea to use message bar in client side.
    1.First create a div at the begining of a page which is always visible.
    2.create some hidden div tags which contains message bars with different error or information messages.
    3. during the validation in javascript if u want to show error message just assign the content of hidden div tag
    to visible div tag.Now u will get error message as like real message bar.
    Then in javascript just write this code
    document.getElementById('sample').innerHTML=document.getElementById('Error').innerHTML
    where sample-->id of visible div
    Error-->id of hidden div inside which u need to write the code for messagebar
    this wiil show the error message at the place of visible div (sample).
    <b>Note:</b>
    If u want to change the messageBar text dynamically that can be possible only through server side only using bean to set and get error messages.
    I am not able to give some sample coding since the code button throws some script error.
    Ragards,
    Tamil K

  • How can I access xml document from javascript whithin a JSP page

    how can I access xml document from javascript whithin a JSP page?
    I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
    Thanks in advance!

    The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
    It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation.

  • How to access another control in a page in another xaml file?

    I have a XAML page name GameMainSP.xaml. Can I access a control in that page from a module in the project? I was only trying to change a text block controls Text property. Is this possible?
    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering
    - Yoda. Blog - http://www.computerprofessions.co.nr

    I have a XAML page name GameMainSP.xaml. Can I access a control in that page from a module in the project? I was only trying to change a text block controls Text property. Is this possible?
    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering
    - Yoda. Blog - http://www.computerprofessions.co.nr
    Nevermind, I managed to figure out what was the problem. I needed to provide a reference to the page.
    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering
    - Yoda. Blog - http://www.computerprofessions.co.nr

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

  • Access Custom Attributes in JavaScript and in Transactions

    Hello,
    I try to work with custom attributes. I've problems accessing the values in JavaScript and in transactions, but it works fine within .irpt pages.
    What's the trick?
    For a custom attribute called PLANT, can I write something like this in JavaScript?
    var p = ;
    Is there a way to access custom attributes in the Link Editor of an Action Block?
    Kind Regards,
    Matthias

    Hi Matthias,
    it is not possible to integrate that kind of MII variables in JavaScript like you discribed before.
    You are right that this kind of expression is possible in the .irpt file. The reason why it is working in the .irpt
    but not in the .js is, that the MII script parser is only replacing in HTML content. Everywhere you have
    scripting the parser will not replace the {...} markings (since the curly brackets also show start/end of functions aso.).
    Variables to JavaScript
    The easiest Way to get those variables is to create hidden fields in the .irpt file that you can access via JavaScript.
    For example:
    <input type="hidden" id="hidden_plant" value="{PLANT}" />
    This will be parsed to (e.g.)
    <input type="hidden" id="hidden_plant" value="Karlsruhe/DE" />
    Now you can access this value in JavaScript via:
    document.getElementById( "hidden_plant" ).value;
    Variables to Transactions
    To parse custom variables to a transaction you first have to specify corresponding transaction variables in the
    transaction itself. After saving the transaction you can map those variables to Parameters in the Xacute-Query-Editor.
    Including this transaction to your webpage you can simply assign the required value to the corresponding parameter.
    For example if you mapped the Plant variable of the transaction to Param.1 you can specify the information in the .irpt
    like:
    <applet id="trx_test" ....>
      <... />
      <param name="Param.1" value="{PLANT}" />
    </applet>
    Another possibility is to set the value dynamically via JavaScript if you use:
    document.getElementById( "trx_test" ).getQueryObject().setParam( 1, "Karlsruhe/DE" );
    Native access to user variables via the BLE is not possible (as far as I know).
    I hope this is what you wanted to hear?
    Best Regards
    Sebastian
    Edited by: Sebastian Holzschuh on Jun 10, 2008 12:16 PM

  • Dynamic Object for Checkbox in HTMLB control

    Hi all,
    I want to create dynamic object for Checkbox in HTMLB control.
    I have created dynamic check box in JSP using JSPDynpage. I can select multiple values in the list of checkbox.After clicking the submit button , I have to read the value of checkbox.  For this first i want to create the object for checkbox in controller.
    How can i create the dynamic object?
    Help me in this regard.
    Thanks & Regards
    Hemalatha J

    Krish
      Will this link helps you ????
      <a href="http://help.sap.com/saphelp_nw04/helpdata/en/7d/9b0e41a346ef6fe10000000a1550b0/frameset.htm">Check Box</a>
    Thanks
    Jack
    Allot points if it helps

  • Access embedded reader with javascript

    For a project I'm looking for a way to display pdf files within a webbrowser. I have IE8+ with acrobat reader available to me, so i can display any given pdf. But i would like to be able to change pages, jump to bookmarks with javascript functions in my html page.
    So in other words: does acrobat reader have somesort of api through which i can access my document using javascript?

    Post the query in the forum for Acrobat SDK.

  • Need to set the tab order in HTMLB controls

    I readed in another thread that it was not possible to set the tab order in HTMLB controls on BSP forms.
    However it was possible to do a little workaround, by setting the tooltip property, and put in the tabindex in that. Because Browsers do understand the property tabindex.
    Examble:
    <htmlb:inputField id="authorfname1"
    tooltip='tooltip1" tabindex="2'
    value = "<%= authorfname %>" />
    HTML Output would be like this:
    <input title="tooltip1" tabindex="2" class="sapEdfTxtEnbl"
    size="20" name="authorfname1" id="authorfname1" value="">
    <b>It works a little bit differently in my HTMLB controls.</b> Output is like this:
    <input title="tooltip1&quot; tabindex=&quot;2" class="sapEdfTxtEnbl"
    size="20" name="authorfname1" id="authorfname1" value="">
    <i>It doesn't work. " becomes &quot; <b>How do I solve this?</b></i>

    thanks for sharing the info.
    to handle your issue you could do the following
    <% data: replace_string type string .
    clear replace_string .
    replace_string = `<input  tabindex="2"`.
                  %>
                  <bsp:findAndReplace find    = "<input"
                                      replace = "<%= replace_string                  %>" >
                   <htmlb:inputField id="authorfname1"
    tooltip="tooltip1"
    value = "<%= authorfname %>" />
                  </bsp:findAndReplace>
    Hope this helps.
    Regards
    Raja

  • Is double clicking home button to access music controls the best ways?

    Currently user need to double click the home button to access music control, while the phone is locked.
    I understand now since users r familiar with iphone controls this interaction is not bad to have but not the best interaction type.
    Instead the clock area could be swappable to music controls & mayb even weather.
    cheers

    You can also go to settings / music

Maybe you are looking for