Topic
5 replies Latest Post - ‏2013-12-21T17:53:28Z by harinagendra
SarithaBB
SarithaBB
3 Posts
ACCEPTED ANSWER

Pinned topic JSF- JavaScript Issue

‏2011-11-22T12:08:05Z |
Issue with java script in WebSphere7.0.0.19
Updated on 2012-01-07T05:52:29Z at 2012-01-07T05:52:29Z by evantanski
  • SarithaBB
    SarithaBB
    3 Posts
    ACCEPTED ANSWER

    Re: JSF- JavaScript Issue

    ‏2011-11-22T12:10:45Z  in response to SarithaBB
    Here is the detailed issue of the javascript error. On click of ok button in the below code, it is not navigating to the corresponding dummy.jsf page, which is in the same location as the below jsf. Please check the detailed code below.
    ************************************************************************
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <%@page import="javax.faces.context.FacesContext"%><f:view>
    <html>
    <body>
    <h:form id='abc' >
    <input type="text" name="textField" />
    <h:commandButton id="addBtn" value="OK" onclick="return(sendAction())" />

    </h:form>
    </body>
    <script>
    function sendAction(){
    document.forms.action = "dummy.jsf";
    document.forms.submit();
    return false;
    }
    </script>
    </html>
    </f:view>
  • seohulu
    seohulu
    6 Posts
    ACCEPTED ANSWER

    Re: JSF- JavaScript Issue

    ‏2011-11-22T15:12:42Z  in response to SarithaBB
    using "document.forms[0].submit();" rather than "document.forms.submit();"
    Acoolme is an Online Marketing Software Platform And Social Community
    • SarithaBB
      SarithaBB
      3 Posts
      ACCEPTED ANSWER

      Re: JSF- JavaScript Issue

      ‏2011-11-23T05:31:42Z  in response to seohulu
      Here is the detailed description of the issue. We would like to raise a ticket with IBM support team for this. Please help.

      Environment 1 -- WebSphere 6.1, JDK1.5, JSF 1.1, JavaScript Environment 2 -- WebSphere 7.0.0.19 (With Fix Pack 19), JDK1.6, JSF 1.1, Javascript

      We have come up with sample code and executed this in both Environment 1 and Environment 2. This sample code is working and loading the next page in Environment 1 but not in Environment 2

      On click of OK button in the below code, it is not navigating to the corresponding dummy.jsf page(through javascript),

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@page import="javax.faces.context.FacesContext"%><f:view>
      <%
      System.out.println("Test");
      FacesContext fc = FacesContext.getCurrentInstance();
      HttpServletRequest request1 = (HttpServletRequest) fc.getExternalContext().getRequest();
      System.out.println("Request Field Value in JSP " + request1.getParameter("textField"));
      %>
      <html>
      <body>
      <h:form id='abc' >
      <input type="text" name="textField" />
      <h:commandButton id="addBtn" value="OK" onclick="return(sendAction())" />

      </h:form>
      </body>
      <script>
      function sendAction(){
      document.forms.action = "dummy.jsf";
      document.forms.submit();
      return false;
      }
      </script>
      </html>
      </f:view>
      I deployed the above code in Environment 2 and invoked the url.

      I cicked on Go button in the above screen. I can see the url is updated to dummy.jsf, but the content in dummy.jsf is not reflected.
  • evantanski
    evantanski
    6 Posts
    ACCEPTED ANSWER

    Re: JSF- JavaScript Issue

    ‏2012-01-07T05:52:29Z  in response to SarithaBB
    As soon as JSF renders h:inputText into <input type="text"> html tag, you can do the same you did previously. I.e. use onkeypress attribute on the input Text

    Frostwire Download
    • harinagendra
      harinagendra
      1 Post
      ACCEPTED ANSWER

      Re: JSF- JavaScript Issue

      ‏2013-12-21T17:53:28Z  in response to evantanski

      Hi Saritha,

      I am also migration my application from WAS 6.1 to WAS 7.0 and facing the same issue. Could you please let me know how you have resolved this issue.

      Previously I have faced one more issue with onlclick in h:commandButton where we have to navigate to another page when we clicked on the button. But we haven't used document.forms(0).submit(). however we have used href directly calling the  particular (.do) . I have resolved by mentioning return false after the onclick method.

      Ex:

      In WAS 6.1

      onclick=example();return true;

      I have changed as below to make the code work in WAS 7.0.

      onclick=example();return false;

      I didn't actually understand what actually made return false to work  in WAS 7.0. If return is true same JSP is loading with blank/null values.