Announcement Announcement Module
Collapse
No announcement yet.
java.lang.IllegalStateException: while Adding text boxes dynamically via javascript Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.IllegalStateException: while Adding text boxes dynamically via javascript

    Hi

    I am trying to implement a form which would initially display four text boxes.
    Additionally the user will be given an add rows button by which he can create dynamically another row of four text boxes.
    I wrote a simple javascript function to add rows dynamically using an example code of matt fleming from the net.

    When i try to render the form for the first time then i am getting the following error.
    ************************************************** ********
    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException: Exception in JSP: /jsp/ratekeys/RkUsageMaster.jsp:49

    46: var newdiv = document.createElement('div');
    47: newdiv.setAttribute("id", divIdName);
    48: newdiv.innerHTML = " <TR> <td class=label> <fmt:message key='rkusage.id.sfusagebandid' /> * </td> "+
    49: " <td class=control> <form:input path='arrStRkUsage["+(numSlabCountValue - 1)+"].id.sfUsageBandId' size='20' maxlength='15' tabindex='"+(numMaxTabIndexValue + 1)+"' /> </td></tr>";
    50: ni.appendChild(newdiv);
    51: }
    52:


    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:504)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:387)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:240)
    org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:252)
    org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1173)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:901)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:809)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)


    root cause

    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'arrStRkUsage["+(numSlabCountValue - 1)+"]' available as request attribute
    org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:141)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getBindStatus(AbstractData BoundFormElementTag.java:172)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getPropertyPath(AbstractDa taBoundFormElementTag.java:192)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.getName(AbstractDataBoundF ormElementTag.java:158)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.autogenerateId(AbstractDat aBoundFormElementTag.java:145)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.resolveId(AbstractDataBoun dFormElementTag.java:136)
    org.springframework.web.servlet.tags.form.Abstract DataBoundFormElementTag.writeDefaultAttributes(Abs tractDataBoundFormElementTag.java:120)
    org.springframework.web.servlet.tags.form.Abstract HtmlElementTag.writeDefaultAttributes(AbstractHtml ElementTag.java:379)
    org.springframework.web.servlet.tags.form.InputTag .writeTagContent(InputTag.java:139)
    org.springframework.web.servlet.tags.form.Abstract FormTag.doStartTagInternal(AbstractFormTag.java:90 )
    org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:7 7)
    org.apache.jsp.jsp.ratekeys.RkUsageMaster_jsp._jsp x_meth_form_input_0(RkUsageMaster_jsp.java:546)
    org.apache.jsp.jsp.ratekeys.RkUsageMaster_jsp._jsp Service(RkUsageMaster_jsp.java:131)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:240)
    org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:252)
    org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1173)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:901)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:809)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)

    ************************************************** ********

    The exception in BOLD RED is thrown at the line of code inside the javascript function addSlabRow().
    The code of the function is as follows:

    function addSlabRow()
    {
    var ni = document.getElementById('myDiv');
    var numMaxTabIndexValue = document.getElementById('MaxTabIndexValue');
    var numSlabCountValue = (document.getElementById('SlabCountValue').value - 1) + 2;
    var divIdName = "my" + numSlabCountValue + "Div";
    var newdiv = document.createElement('div');
    newdiv.setAttribute("id", divIdName);
    newdiv.innerHTML = " <TR> <td class=label> <fmt:message key='rkusage.id.sfusagebandid' /> * </td> "+
    " <td class=control> <form:input path='arrStRkUsage["+(numSlabCountValue - 1)+"].id.sfUsageBandId' size='20' maxlength='15' tabindex='"+(numMaxTabIndexValue + 1)+"' /> </td></tr>";
    ni.appendChild(newdiv);
    }


    Now the problem is that this function is being called on the onclick event of a button defined in the jsp as follows:
    <td class=label>
    <INPUT type="button" class="button"
    value="<fmt:message key="button.addslabrow"/>" name="_addSlabRow"
    onclick="return addSlabRow();" />
    </td>


    Since the addSlabRow() function is not getting called at the time of rendering of the form for the first time. then why is the exception in RED being thrown.
    any help will be greatly appreciated.

    rgds
    harry
Working...
X