Jsp expression inside a onclick event

onClick = "send(<%=layerColl.GetItem(i).GetObjectId()%>)" .... where is expression'll return a alphanumeric id... i want to receive it as a string in a JSP function public send(String a ){}

on my understanding you are calling a javascript function onclick event. eventually you pass the variable as number or object on the function.
like:
<%
String sample = "1";
%>
onClick = "send(<%=sample%>)"the value of the sample string is 1 so the function will be
onClick = "send(1)"and you got error on the javascript in IE like Object Expected
so you need to put the expression inside single quotes like
onClick = "send('<%=sample%>')" correct me if i'm wrong. that is my understanding

Similar Messages

  • Can't set a hidden field value from onClick event with a runtime expression

    Hi,
    I need to set a hidden field in an onClick event of button but it's not working.
    <html:submit styleClass="btnLink" onclick="document.empForm.hidden.value='<%= empID%>'">
    <%= empID%>
    </html:submit>
    Althought the second expression is evaluated and written successfully "the button value"
    I heard that this is because you can't mix the value of an attribute of a custom tag with both string literal and run time expressions.
    Is there any work around to solve that?
    I can't use EL as I'm using old JSP version

    I guess, it should work; instead of html:submit, try with button.

  • Is it possible to send the packae name inside a import as a jsp expression

    Hi,
    I am using jsp pages
    <% @ page import="package names"%>
    How i can pass the package names as a jsp expressions
    Regards,
    ahamad

    I am doing templates.I am forwarding the request
    from other pages to the same page.At that case i
    neeed to change the value which is in import
    attribute.
    Is it possible to avoid hard-coded value inside a
    import attribute.Only by preprocessing the sources. But why would you need to change just an import statement? Wouldn't you have to replace all class references as well?

  • Deferred expressions inside JSP tags

    Hello!
    I want to include custom JSP 2.0 tag into page.
    Something like
    <!-- Page.jsp -->
    <jsp:root version="2.0"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:jsp="http://java.sun.com/JSP/Page"
        xmlns:pk="urn:jsptagdir:/WEB-INF/tags">
        <jsp:directive.page language="java"
            contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
    <f:view>
    <pk:custTag bean="${beanInstance}"/>
    </f:view>
    </jsp:root>inside that tag I want to access my bean in JSF 1.2 way:
    <!-- custTag.tag -->
    <jsp:root version="2.0" xmlns:h="http://java.sun.com/jsf/html">
    <jsp:directive.tag body-content="empty" language="java"
            pageEncoding="ISO-8859-1" />
    <jsp:directive.attribute name="bean" required="true" type="com.my.Bean"/>
    Runtime way:
    ${bean}
    ${bean.prop}
    Deferred way:
    <h:outputText value="#{bean}"/>
    <h:inputText value="#{bean.prop}"/>
    </jsp:root>So ${} renders as expected, but <h:outputText> renders nothing as #{} evaluates to null. What should I do to make outputText and inputText work, if that's possible at all?
    I use Tomcat 6.0.2 and JSF-RI 1.2_03.
    Thanks,
    Alexey

    Oh, I see now.
    But is there a way to trick JSF by explicitly putting bean into request scope? Something, like Tomahawk's aliasBean?
    Actually, I did try to implement it. The following code was supposed to create a variable in EL-context:
    ValueExpression     expr = _value instanceof ValueExpression
                       ? (ValueExpression)_value
                       : facesContext.getApplication().getExpressionFactory().createValueExpression(_value, Object.class);
    ELContext   ctxt = facesContext.getELContext();
    VariableMapper varMap = ctxt.getVariableMapper();
    if ( varMap == null ) {
        ((ELContextImpl)ctxt).setVariableMapper( new VariableMapperImpl() );
        varMap = ctxt.getVariableMapper();
    if ( varMap != null ) {
        varMap.setVariable(_alias, expr);
        _active = true;
        log.fine("makeAlias: " + _alias + " = " + expr.getExpressionString());
    } else {
        log.warning("makeAlias: " + _alias + " = " + expr.getExpressionString() + " failed");
    }But resolving #{...} still returned null.

  • Calling jsp custom tag from jsp expression

    hi there,
    I have a problem calling oracle(or any other) custom tag from inside a jsp expression.(i.e.)embeding <jbo:tagname...> into <%......%>.
    For example:
    I need to get the value of a jsp parameter, but the parameter name is dynamic (retrieved from a DataBase)
    So I though it would be something link that:
    <%=request.getParameter(<jbo:ShowValue datasource="ds" dataitem="ParamName" ></jbo:ShowValue>) %>
    where <jbo:ShowValue is an Oracle custom tab that retrieves the value of a certain dataItem(certain field).
    But it does not work.........
    if any body can tell me how to overcome, or work around it, I'll be so pleased.
    Regards,
    Remoun Anwar

    Hi,
    You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
    Hope u got the answer...
    Regards
    ravi

  • Error in form submit through netui:anchor tag onClick event

    Hello,
    I am working on a portal application. Below is my jsp code of a simple search screen. The search parameter is customername.
    <netui:form action="searchCustomer" style="form" tagId="myForm">
    <netui:textBox dataSource="{actionForm.customerName}"></netui:textBox>
    <netui:anchor onClick="sayHello(); return false;" styleClass="button" action="searchCustomer" formSubmit="true"> Search</netui:anchor>
    </netui:form>
    I have an onClick event as I want to implement some customer logic on click of the anchor tag.
    function sayHello(){
    // customer implementation here
    document.forms[getNetuiTagName("myForm",this)].method="POST";
    document.forms[getNetuiTagName("myForm",this)].action="/searchCustomer.do";
    document.forms[getNetuiTagName("myForm",this)].submit();
    In the searchCustomer method of the controller, the form has zero parameters. The customerName has null value.
    Can anyone tell me what am I doing wrong here.
    Any help is appreciated.
    Thanks
    Manju

    I also want to add a confirm() dialog before submitting. However, setting the onClick handler overrides the one generated when formSubmit="true". I worked around this by calling the generated function directly:
    <... onClick="if (confirm('[msg]')) { anchor_submit_form(getNetuiTagName('[formName]'), this.href) } return false;">
    Where [msg] is the message to display and [formName] is the name of the form containing the anchor.
    Hope this helps someone.

  • How to invoke a Servlet on onClick event of CheckBox ?

    Hi,
    Can anybody provide me with the code - how to invoke a Servlet & then pass all form variables to the Servlet on onClick Event of CheckBox in a JSP Page.
    I guess it is possible with Javascript but i need the code...
    Pls Help !
    Thanx.

    <html>
    <head>
    <script language="JavaScript">
    <!--
    function submitMyForm(){      
    document.myform.submit();
    //-->
    </script>
    </head>
    <body>
    <form name="myform" method="POST" action="http://mywebserver/servlet/myServlet" target=_top>
    <input type="checkbox" name="mycheckbox" OnClick = "javascript:submitMyForm()">
    </form>
    </body>
    </html>
    Hope this helps...

  • Possible to run javaBean in onClick event?

    Hello everybody,
    Does anybody know if it is possible to run javaBean from onClick event in JSP,
    for example:
    .... onClick="<%bean.doSomething()%>" .......
    It does not work for me, perhaps it is a syntax error??
    Best regards,
    danny

    Hello everybody,
    Does anybody know if it is possible to run javaBean
    from onClick event in JSP,
    for example:
    .... onClick="<%bean.doSomething()%>" .......
    It does not work for me, perhaps it is a syntax
    error??
    Best regards,
    dannywell it wont work, coz onClick event is a client side event which will execute in the browser, to run an server event u have to load a page in a new window so that when the page load it would execute the doSomething() methodof the bean.

  • Javascript Submit button onclick event handler

    Hi,
    I am having trouble getting the onclick event handler of a form to execute when the button is pressed. I am trying to open a page in a new window depending on if the user selects that option in a checkbox.
    There is one form(id='graphform') and 2 submit buttons, each with a checkbox before it. I want the new window to open only iuf the right checkbox and matching submit button has been checked.
    One of the checkbox/button pair: The onclick="checkWindow('w1','graphform');" is never getting called.
    <input type="checkbox" id="w1" name="win1" style="margin-right: 10px" value="window"  onclick="javascript:document.gform.win1[0].checked = true;"><a style="margin-right: 10px">Graph in new window</a>
    <input type="submit" value="Create graph" onmouseover="this.form.cumulat.value='0';this.form.graphGroup.value='Consumption'; document.getElementById('hintSubmitStop').value='1';" onclick="checkWindow('w1','graphform');" onmouseout="document.getElementById('hintSubmitStop').value='0';" /></td></tr>Javascript window opener:
    function checkWindow(win1, str){
              var formObj = document.getElementById(str);
         var checkBoxObj = document.getElementById(win1);
         if(checkBoxObj1.checked == true){
                   formObj.target = "_blank";     
                   formObj.action = "graphDisplayFrame.jsp";     
         else if(checkBoxObj1.checked == false){
                   formObj.target = "_self";
                   formObj.action = "graphDisplay.jsp";
    }Any suggestions?
    J

    You're storing the value in "checkBoxObj" and in the next line you use different variable name as "checkBoxObj1".
         var checkBoxObj = document.getElementById(win1);
         if(checkBoxObj1.checked == true){
    instead of "true', try      if(checkBoxObj.checked == 1){

  • Trim() in JSP expression

    Hello!
    I'm trying to use trim() on a session variable, inside a JSP expression. Something like:
    <%= "Dear " + session.getAttribute("tmpFrstName").trim() +"\nHere's the next paragraph" %>
    Using it as above gives the following error -
    Error: No method named "trim" was found in type "java/lang/Object".
    Thx

    session.getAttribute returns an object, in order to use trim convert or cast it to string object and then apply trim like
    session.getAttribute("tmpFrstName").toString().trim()

  • Unable to capture onClick event of htmlb:image in a controller

    Hi,
    I am trying to capture onClick event of an htmlb:image (which is present in my view) in DO_HANDLE_EVENT method of my controller.
    Surprisingly, when I click the image, page does refreshes. But the event in not captured in do_handle_event method. Control never reaches that method. Whereas if I put onClick event of a button, it is easily captured in do_handle_event method.
    Ex. code in my view is:
    <%@page language="abap"%>
    <%@extension name="bsp" prefix="bsp" %>
    <%@extension name="htmlb" prefix="htmlb"%>
        <htmlb:image id      = "searchimg"
                     src     = "consvalue.jpg"
                     onClick = "search"  />
        <htmlb:button id="searchbutton" onClick="search"
                                     text="Event Test"/>
    Now, the button event is captured, but not the image event.
    Any idea why this might be happening?
    Regards,
    Kaushal

    Hi Kaushal,
    are image and button enclosed by <htmlb:form> ?
    Please post your of do_handle_event, where you look for the event.
    Regards,
    Sebastian

  • JSP 1.2: jsp expression in attribute value doesn't parse.

    Hi, I'm trying to use a jsp:expression in an html attribute value in JSP 1.2 but jasper doesn't seem to be able to parse it correctly. I'm using the XML syntax in my jsp, the relevant snippets are as follows:
    <jsp:scriptlet>
    String versionedPath = "/mysite/2.1/images";
    </jsp:scriptlet>
    <img src="%= versionedPath %/foo.jpg" />
    The JSP documentation claims that this will work but I'm beginning to think this syntax won't work when using JSP's XML syntax. I already know that the following won't work:
    <img src="<jsp:expression> versionedPath </jsp:expression>/foo.jpg" />
    as it did in JSP 1.1 because it's not well-formed xml.
    Is it even possible to use jsp expressions in attribute values when using JSP 1.2's XML syntax? If so, please enlighten me, and if not, well, that seems pretty broken to me.
    TIA...
    --Stuart

    you should use this:
    <img src=<%= versionedPath %>/foo.jpg >

  • Help needed in JSP Expression Language

    Hi all,
    I have been working for JSP Expression Language Sample execution since past 5 days. I am using the application server as "Jboss Server" and web server as "Tomcat".
    I have been included the jsp-api.jar file in my lib directory of application server as well as source folder's lib directory.
    When i am trying to build the source code, i am getting this build error.
    [javac] D:\eclipse\workspace\esolvProject\development\src\com\esolv\taglibs\
    web\classes\SetSupport.java:186: cannot resolve symbol
    [javac] symbol : method getExpressionEvaluator ()
    [javac] location: class javax.servlet.jsp.PageContext
    [javac] ExpressionEvaluator evaluator = pageContext.getExpressionEvaluator();
    In my jsp-api.jar , there are two classes called,
    PageContext and JspContext, Both are abstract classes.
    PageContext inherits JspContext class. JspContext class have the method getExpressionEvaluator() , returns ExpressionEvaluator.
    PageContextImpl - class . it has been called internally when we are trying to call PageContext class. In PageContextImpl class, there is one comment before, the method's definition. that is
    " Since JSP 2.0 "
    But we have the JSP 2.0 version. But it won't work.
    Please help me ont this.
    Thanks in Advance,
    Natraj

    >
    If the pblm was due to setting the classpath.
    The error should be showed for all files in the jar
    file.
    why i am getting the error for particular method ?
    it is accessing the other methods of same class
    'JspContext' . but it is not accessing that method.
    Thats my question.
    Just check that your .jar file is 2.0 compliant and that you do not have any other jars(for servlet or jsp api) in the classpath.
    Probably you have an older version of .jar file in your path. So the errors will appear only for those methods that have been added since 2.0, all other methods would compile fine.
    Please tell me the jar files to work out the
    expression language. so that i can cross check my
    list of jars.Hmmm...I dont use jboss. In tomcat the jar file name is jsp-api.jar. But it would have been the same even for jsp1.1, going by jar file names wouldnt help. Just look at your cp as if with a microscope to identify redundant jars.
    cheers,
    ram.

  • JSP ${} expressions in JSF tag attributes

    Does anyone know why the expert group decided not to allow ${} style expressions within JSF tag attributes? I understand that a different syntax is needed to implement the 'late binding' #{} expressions used to link input controls to form beans, but not why the JSF tags actually prevent the use of immediately evaluated ${} expressions for accessing variables in the page scope in JSP 2.0.
    I know there has been a lot of discussion about this and other threads mention a security loophole that would be opened up by allowing expressions like #{blah.${someProperty}}, but I'm not sure why this sort of thing would cause a problem. Is there any way to enable this behaviour, such as editing the JSF tag library descriptors to allow runtime expressions (horrible though that sounds)? Or perhaps another JSF implementation that supports both immediately evaluated and late-binding expressions? It seems a rather unnecessary restriction that is going to cause much confusion and mistyping for all...
    Thanks in advance,
    Keith.

    Thanks Adam, I see the problem now. It's a fairly obscure loophole but serious nonetheless. Of course, this problem could also be avoided by not using request parameters within JSF tags as it doesn't affect the majority of legitimate uses for expressions.
    I have to disagree with you about mixing ${} and #{} expressions though. The majority of developers will be used to writing ${} expressions in JSTL and JSP text and so will expect them to do work the same in JSF tags. Judging by the number of posts in this forum about being unable to use page scope variables in JSF tags this issue is already confusing a lot of people.
    As a rule of thumb, "use ${} for expressions that are output to the page and #{} for binding controls to backing beans and invoking methods" (which perform clearly distinct functions) is a lot simpler and easier to learn IMHO than the current one, which is "use ${} for expressions that are output to the page except within a JSF tag, where you use #{} for the same thing and also to update form values and invoke action methods"! (OK, I'm exaggerating a little for effect, but you get the point... :-)
    I agree that mixing both types of expression in the same attribute might be a little confusing, but this is an unlikely edge case that should probably be prevented in value binding or action attributes anyway. It's more of an issue for label values where mistyping one for the other is already very common and, although not especially difficult to debug, is just another pitfall awaiting the unwary JSP developer. I'm not sure that JSP expressions would be much more difficult to debug anyway as the value and method bindings will simply not work, which is pretty obvious as soon as you try and test the thing.
    Is this something that the EG would be prepared to reconsider for the next release of JSF, or perhaps getting the security loophole addressed in the next JSP spec? In the meantime, is there any reason that developers shouldn't enable runtime expressions in the TLD file provided that they're willing to live with the consequences?
    (Sorry to harp on about it, but I've already had several complaints about this after recommending JavaServer Faces for a major development project at ingenta.com.)
    Many thanks,
    Keith.

  • I have a button in JSP page inside an UIWebView by pressing the button i want to run another existing iPhone native application in background only.Do anyone have a solution for this.

    I have a button in JSP page inside an UIWebView by pressing the button i want to run another
    existing iPhone native application in background only.Do anyone have a solution for this.

    Sounds like a virus.... I hope it's not...
    Launching Other Apps within an iPhone

Maybe you are looking for

  • How to change the status value?

    Hi Experts We landed in the starnge situation. We defined a multi task EE Monitor activity to change the status attribute to past due when particular internal event code is overdue. We forgot to assign the correct EE monitor Activity to EE Profile an

  • How to track the flow of data from R/2 to BI ?

    Hi Experts, Question: How to track the flow of data from R/3 to BI ? I want to load master data from R/3 to BI. In BI, i create an infopackage to load data from R/3. Under processing tab i set it as "PSA and then in the InfoObject (package by package

  • Error Deficit of PU IR quantity

    Hi W hen i tried to post goods reversal (102 MVMT) the error  "Deficit of PU IR quantity xxxxxxx" coming Could you please suggest what is the cause Regards Subbu

  • Would like to re-establish Preview as default pdf program -

    After installing Adobe Acrobat Pro, it became the default PDF program. I would like to re-establish Preview as the default PDF program. I have referred to preferences in each program, but can't get Preview to be default unless I completely remove Acr

  • I am unable to open new tabs. I have downloaded the extension, but still no tabs.

    I have tried everything the website has suggested, yet I am still unable to open new tabs.