0 Replies Latest reply: May 16, 2012 7:25 AM by 876464 RSS

    Add javascript function in a .jspx page

    876464
      Hello,

      I have a jspx page (with the Render in Mobile device option ) selected. I have the following code

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      <%@ page contentType="text/html;charset=UTF-8"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
      <%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
      <%@ taglib uri="http://xmlns.oracle.com/dss/trinidad/faces" prefix="dvtt"%>

      <%@ page language="java"%>
      <%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>
      <%
      String userAgent = request.getHeader("user-agent");
      %>

      <%
      String str="Hello World";
      %>




      <f:view>
      <trh:html id="h1" binding="#{backingBeanScope.backing_FirstPage.h1}">
      <trh:head title="FirstPage" id="h2"
      binding="#{backingBeanScope.backing_FirstPage.h2}">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

      </trh:head>
      <trh:body id="b1" binding="#{backingBeanScope.backing_FirstPage.b1}" onload="show_alert()">
      <h:form id="f1" binding="#{backingBeanScope.backing_FirstPage.f1}">
      <af:panelHeader text="Title"
      binding="#{backingBeanScope.backing_FirstPage.ph1}"
      id="ph1" styleClass="toolbar">
      <af:commandButton text="Forward"
      binding="#{backingBeanScope.backing_FirstPage.cb2}"
      id="cb2" styleClass="button"/>



      </af:panelHeader>
      <af:commandButton text="Back"
      binding="#{backingBeanScope.backing_FirstPage.cb3}"
      id="cb3" styleClass="backButton"/>
      </h:form>
      <%out.print ("USER AGENT IS " +userAgent);%>
      <trh:script text="javascript">
      function show_alert()
      {
      var p = "<%=userAgent%>";

      var s = '&lt; %=str% &gt;' ;
      alert("The val" + s);

      }


      </trh:script>



      <tr:document title="index">
      <f:facet name="metaContainer">
      <f:verbatim>
      <link rel="stylesheet" href="styles/symbian.css"/>
      </f:verbatim>
      </f:facet>
      </tr:document>

      </trh:body>
      </trh:html>
      </f:view>
      <%-- oracle-jdev-comment:deviceCategory:pda--%>
      <%-- oracle-jdev-comment:auto-binding-backing-bean-name:backing_FirstPage--%>


      The problem occurs in the code

      <trh:script text="javascript">
      function show_alert()
      {
      var p = "<%=userAgent%>";

      var s = '&lt; %=str% &gt;' ;
      alert("The val" + s);

      }

      Throws error at "<% , says encountered literal,expected keyword,expression,brace,bracket or operator.

      Please help.