Javascript back on JSF commandButton

I am having a problem trying to add an onclick event to my JSF commandButton. All I want it to do is perform a simple "history.back();". I can put a simple "alert();" for the onclick event and that works just fine. Also if I use an ADF commandButton instead it works just fine. Any ideas on what the problem could be?

I think your problem lies elsewhere on the page.
I had a similar problem and posted on it yesterday. See my post titled:
Why can't I access my button click method?
I could get the alert() method to work, but not the button click that followed.
The problem I had was completely unrelated to the javascript itself.
It had to do with binding to another component.
When I removed that binding, everything worked.
If you can get the alert() message, then you are accessing your onclick method.
I would suggest creating a new page that just contains the single button and it's onclick method.
If that works, then you have a problem elsewhere on the page.
The next thing I would do is to remove any bindings on the other components.
If that works, then put the bindings back until you find the error.
The only reason I am focusing on bindings is because that is what caused my problem.
Hope this helps.

Similar Messages

  • How to do Javascript validations in JSF

    Hi ,
    I want to know about the javascript validation in JSF. I want to know simple validations like field should not be empty.
    I have a problem with my code can any one suggest me on this. for your reference here i'm attaching my code.
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <f:view>
         <%@ include file="../includes/header.jsp"%>
         <h:form id="createForm">
              <script>   
             function validate() { 
                 if((document.createForm.courseId.value=='') ||(document.createForm.courseId.value==null))
                    alert("Please Enter Course Id");     
                     return false; 
                 if(document.createForm.fileName.value=='')
                    alert("Please Enter File Name");     
                     return false; 
                   retutrn true;
                         </script>
              <table width="768" height="100%" border="0" cellpadding="0"
                   cellspacing="0">
                                  <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           Course Id:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="courseId"  value="#{bean.courseId}"  required="true"  />
                                                      </td>
                                                 </tr>
                                                 <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           File Name:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="fileName" value="#{bean.fileName}" />
                                                      </td>
                                                 </tr>
                                            </table>
                                  <tr>
                                       <td colspan="2" align="center" class="formtext">
                                            <h:commandButton value="Create"
                                                 action="#{control.getSelectedItems}"
                                                 onclick=" return validate();" />
                                       </td>
                                  </tr>
                             </table>
                        </td>
                        <td width="12" valign="top" background="images/tile_left_right.jpg">
                             <img src="images/tile_left_right.jpg" width="6" height="1" />
                        </td>
                   </tr>
              </table>
         </h:form>
         <%@ include file="../includes/footer.jsp"%>
    </f:view>

    Have you checked the element ID's? Maybe you have overlooked the woodstocked ID's. Look in the generated HTML source and base your Javascript on this.

  • JSF commandButton with Parameters

    Hello,
    How can I pass parameters to backing bean through commandButton?

    Could you pl tell me how to pass parameter thru CommandButton
    I have the following situation
    1) greetingList.faces which list the Ids & greeting Text
    Id Text
    1 Hello World
    2 Hello World
    2) Pl note Ids are h:commandLink. A click on the Id will render greetingForm.faces with data pertaining to that Id and with Update h:CommandButton
    3) When i click Update button it results in the following error
    javax.faces.FacesException: Error calling action method of component with id greetingForm:_id4
    Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{greetingForm.update}
    Caused by: java.lang.NullPointerException
    So i verified with h:message that Id is passed as Null when click on Update button. I also checked greetingForm.faces has a not null value by printing <h:outputText value="#{greetingForm.message.id}"/>
    So i guess the Id value is overwriteen with null. Also i have defined Id as property in managed bean
    <managed-bean-name>greetingForm</managed-bean-name>
    <managed-bean-class>com.mycompany.GreetingForm</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>id</property-name>
    <value>#{param.id}</value>
    </managed-property>
    Any pointers/suggestions at the earliest on how to pass the value of Id on a click of update button from greetingForm.faces to greetingForm.java will be highly appreciated
    I am willing to upload my war file
    Regards
    Bansi

  • Javascript/jQuery and JSF

    I'm trying to implement a custom JSF component using JSF 2.0 and Javascript/jQuery. The component I'm trying to make is a sortable list whose order can be bound to a collection in the backing bean and whose event (order changed) can be caught with a listener. My question is how would I link the Javascript event so that JSF can catch it (since a list item is not an input component, or button or link)? I know I could listen to the Javascript event and then fire a click event on a hidden commandButton but I'm wondering if there's a more elegant solution (since I'd also prefer a custom event rather than just ActionEvent). Any help would be very much appreciated. Thank you.

    OK, now I'm really green at this so I don't imagine that I can be much help. I'm new to JSF and trying to learn it myself, but I too have an interest in creating components using jQuery. I really don't have a handle on this stuff...yet, but if I had to guess: I'd say your best bet would be to use the new built-in ajax features of JSF 2.0. <f:ajax render="..." event="valueChange"/> Java Server Faces has implemented it's own valueChange event. I don't know how to use this stuff yet though so I can't be of any help other than making this suggestion. Creating your own custom event may be a bit more difficult. I'm guessing you might need to dig into the guts of the expression language and mess with ELResolver and what not. I don't know yet, I'm still studying it.
    Mark

  • Problem using javascript to submit jsf form, values not submitted

    Greetings!
    I have a t:selectOneMenu where I want the page to be submitted when they change the selected value. At this point, I am able to get the form to submit and reload the page, which is all fine. The problem is that none of the values from the page are not set in the backing bean. I have break points on the setter methods that are not being hit.
    I have tried a number of things from searching multiple forums, but here are snippets from my latest version...
    <h:form>
    <t:commandLink id="hiddenLink" forceId="true" value="test link"
    action="#{pc_PageX.doBtnHiddenLinkAction}"></t:commandLink>
    <t:selectOneMenu id="pageList_top" forceId="true" value="#{pc_PageX.ValueX}"
         onchange="jspellSync(); submitPageX();">
         <f:selectItems value="#{pc_PageX.ListX}" />
    </t:selectOneMenu>
    </h:form>
    function submitPageX(){
         var hiddenLink = document.getElementById("hiddenLink");
         hiddenLink.click();
    }Note that the <t:commandLink> is not hidden, though it will be in the final version if I can get this to work.
    If I click the commandLink myself, the page is submitted with all the page values as expected. If I change the list value, thus using javascript to fire the commandLink's click event, the page is submitted with NO values.
    Can anyone come up with an explanation for this behavior? Or better yet, a solution?
    A couple other things I've tried...
    - Not using a commandLink and using jsf's submit function -> onchange="jspellSync(); submit();"
    - Clicking the link using other ways -> hiddenLink.fireEvent('onclick');
    If all else fails, I'll just add a button that they have to click to submit the form.

    snotmare wrote:
    BalusC wrote:
    I recall this problem in one of the ancient JSF versions. Which JSF version do you use? Do you have any room to upgrade to latest? We're using an IBM implementation of JSF, which is at version 7.0. The IBM implementation appears to be built on the JSF base 1.1.That's not an IBM JSF implementation, they do not have any one, they just have some component libraries which runs on top of some JSF implementation. RAD/WSAD ships by default with Sun JSF RI. Try upgrading to at least 1.1_02 which you can download from the aforementioned link. There's a gap of 2 years (and inherently a lot of bugfixes) compared to 1.1. If the application server used supports Servlet 2.5, you could even upgrade to the latest 1.2.
    We've had other issues with the IBM implementation, which could be the cause in this case too. We've been talking about switching to MyFaces, but there is one feature of the IBM version that we like. It's basically a script collector (hx:scriptCollector) that allows us to do pre-processing on the page.As said before, IBM does not have a JSF implementation. So replacing RI by MyFaces wouldn't make any difference.

  • JavaScript problem with JSF

    Hi All,
    Hi All,
    Studio Creator has generated this code
    <h:form binding="#{general$forgotpassword0.form1}" id="form1">
    <h:inputText binding="#{general$forgotpassword0.txtLogin}" id="txtLogin" styleClass="frmObjects" />
    <h:commandButton action="#{general$forgotpassword0.btnSubmit_action}" binding="#{general$forgotpassword0.btnSubmit}"
    id="btnSubmit" onclick="alert('hello'); return checkLogin();" styleClass="frmObjects1" title="btnSubmit" value="Continue"/>
    </h:form>
    now after compilation, I get form1:txtLogin for txtLogin
    Now how can I perform client side JavaScript Validation on form1:txtLogin??
    Thanks
    Sudhakar

    The Id 'form1:txtLogin' is valid in SUN RI implementation but with myfaces, the ID can be different (the id generation depends on the implemented algorythm).
    I use the j4j.jar containing the component 'proxytag' to get the client Id generated by JSF engine. See http://www.jsftutorials.net/proxyTag.html
    Afterwards, you can manipulate the component via javascript by using document.getElementbyId("");

  • Javascript confirm form jsf

    Hello,
    In my project I have to search for a person in two tables A and B. The search method in the backing bean should do something like this: search in table A, then in case the person was not found, prompt the user for confirmation on searching in table B.
    How can this be done with jsf?
    Thank you,
    Ioana.

    I'm sorry. I was not clear. I know I can use javascript from jsf. I want to use javascritpt from the backing bean.
    So in the action method I search table A, then ask for confirmation and proceed with table B or not, depending on the user's choice.
    Ioana.

  • JSF - commandbutton action firing commandlink action too

    Hi,
    I have a very weird problem. I googled on web and could not find anybody who faced this issue. Not sure if its my code.
    I have following commandlink with a datatable
    <h:commandLink id = "downloadfileid"
         value="#{usn.requeststatus}"
    action="#{DisplayExcelRequestsBean.downloadFile}" immediate="true">
         <f:param id="param1" name="filetoOpen" value="#{usn.requestfilename}"> </f:param>
    </h:commandLink>
    and a commandbutton on the page
    <h:commandButton id="refreshexcel"
    action="#{DisplayExcelRequestsBean.refreshExcelRequests}"
    value="< Refresh >" type="submit" >
    </h:commandButton>
    Both are making call to backing bean to do some action. The issue is when i click on commandlink, the downloadFile() method is executed which is good. But then after clicking on link, when i click on command button, the submit is first firing downloadFile() and then refreshExcelRequest(). Now why is it executing this other method first? I am newbie to jsf so maybe i am doing something wrong. But my understanding is that action should only fire what it is suppose to do.
    Anyhelp is appreciated.
    Thanks,

    Hi,
    Thanks for the responses. I am using JSF version 1.2
    Here is my code for both the methods downloadfile() & refreshExcelRequests(). The code is pretty straightforward.
    public void downloadFile() {
         FacesContext fc = FacesContext.getCurrentInstance();
         String pValue = this.getParam1().getValue().toString();
         File f = new File (pValue);
         HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
         response.setContentType("txt/plain");
         response.setHeader ("Content-Disposition", "attachment;filename=\""+ pValue +"\"");
         FileInputStream fis = null;
         OutputStream os = null;
           //     Load the file in the InputStream
             try {
                    fis = new FileInputStream(f);
                    os = response.getOutputStream();
                    int read = 0;
                    byte[] bytes = new byte[1024];
                    while((read = fis.read(bytes)) != -1){
                       os.write(bytes,0,read);
              os.flush();
              os.close();
              fc.responseComplete();
             } catch (Exception e) {
             return;
    public void refreshExcelRequests() {
             EventDownloadsDBManager edbm = new     EventDownloadsDBManager();
             this.setExcelreqlist( edbm.getEventDownloadRequestByNbkId(this.getLoggedinNBKID()) );
             return;            
    }

  • How to make Javascript access standard JSF component

    Hello all,
    I'm in need of a proper javascript code that access standard jsf component.
    Like we do for html tags;
    if( el.tagName.toLowerCase() != 'select')
    I need to do the same thing for a jsf tag i.e; <h:selectOneMenu>. How to make javascript access <h:selectOneMenu> like it does with <select> tag ? Please let me know asap. Extremely sorry if the question is kind of stupid....cause I'm a beginner for JSF environment.
    Any sort of help, suggestion or advice would highly be appreciated.
    Thanks in advance.

    Ummmm, I may be off the beaten path, but by the time your javascript is called the h:selectOneMenu would be a select tag within the dom. You should be able to reference that tag as you normally would.

  • How to implement JavaScript validation in JSF

    Dear all,
    if i wish to implement JavaScript front end validation function in JSF. what should i do?
    thanks.

    Hi,
    in Core JSF from David Geary there is a chapter on using
    Jakarta Commons Validator for javaScript validation
    source could be found here:
    http://www.horstmann.com/corejsf/
    HTH,
    Matthias

  • Getting javascript error in jsf portlet

    Hi,
    I wrote a jsf page with command links calling an action in ManagedBean. Its works fine if run as jsf page. But when I associate the jsf page with a portlet and run the page, I am getting javascript error when clicked on the command links.
    Please help me to resolve this problem.
    The jsf page
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@ taglib uri="http://www.bea.com/servers/portal/groupspace/tags/activemenus" prefix="activemenus" %>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://bea.com/faces/adapter/tags-naming" prefix="netuix" %>
    <html>
    <head></head>
         <body>
    <f:view>
         <netuix:namingContainer id="facesContent">
              <h:form>
    <f:verbatim>
         <table border="0" width="100%">
              <tr>
                   <td>
                        <h:outputLabel value="Notifications" for="heading"/>
                   </td>
                   <td>
                        (<h:outputText value="#{notificationsBean.notificationsSize}" escape="true"/>)
                   </td>
                   <td>
                             <h:commandLink action="#{notificationsBean.showInWorkList}" immediate="true">
                                  <h:outputText value="Show in Worklist"/>
                             </h:commandLink>
                   </td>
                   <td>
                        <h:outputText value="hai"/>
                   </td>
              </tr>
         </table>
    </f:verbatim>     
              <div style="overflow: auto; width: 100%; height: 200px">
              <h:dataTable value="#{notificationsBean.userNotifs.notificationsList}" var="notification">
                   <h:column>
                        <f:facet name="header">
                             <h:commandLink action="#{notificationsBean.sort}">
                                  <f:param name="column" value="caseNB"/>
                                  <f:param name="sortDirection" value="#{notificationsBean.sortDirection}"/>
                                  <f:param name="pattern" value="####"/>
                                  <h:outputText value="Case ID"/>
                             </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{notification.caseNB}"/>
                   </h:column>
                   <h:column>
                        <f:facet name="header">
                             <h:commandLink action="#{notificationsBean.sort}" immediate="true">
                                  <h:outputText value="From"/>
                                  <f:param name="column" value="senderNM"/>
                                  <f:param name="pattern" value=""/>
                                  <f:param name="sortDirection" value="#{notificationsBean.sortDirection}"/>
                             </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{notification.senderNM}"/>
                   </h:column>
                   <h:column>
                        <f:facet name="header">
                             <h:commandLink action="#{notificationsBean.sort}">
                                  <f:param name="column" value="priorityCD"/>
                                  <f:param name="sortDirection" value="#{notificationsBean.sortDirection}"/>
                                  <f:param name="pattern" value=""/>
                                  <h:outputText value="Priority"/>
                             </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{notification.priorityCD}"/>
                   </h:column>
                   <h:column>
                        <f:facet name="header">
                             <h:commandLink action="#{notificationsBean.sort}">
                                  <f:param name="column" value="subjectTX"/>
                                  <f:param name="sortDirection" value="#{notificationsBean.sortDirection}"/>
                                  <f:param name="pattern" value=""/>
                                  <h:outputText value="Subject"/>
                             </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{notification.subjectTX}"/>
                   </h:column>
                   <h:column>
                        <f:facet name="header">
                             <h:commandLink action="#{notificationsBean.sort}">
                                  <f:param name="column" value="createDT"/>
                                  <f:param name="sortDirection" value="#{notificationsBean.sortDirection}"/>
                                  <f:param name="pattern" value="dd-MM-yyyy"/>
                                  <h:outputText value="Created(ET)"/>
                             </h:commandLink>
                        </f:facet>
                        <h:outputText value="#{notification.createDT}"/>
                   </h:column>
              </h:dataTable>
              </div>
                   </h:form>
    </netuix:namingContainer>
    </f:view>
    </body>
    </html>
    The Managed Bean:
    public class NotificationsManagedBean {
         private UserNotifications userNotifs=new UserNotifications();
         private int notificationsSize;
         private String column;
         private String sortDirection = "asc";
         private String pattern;
         public UserNotifications getUserNotifs() {
              getUserNotificationsList();
              return userNotifs;
         public void setUserNotifs(UserNotifications userNotifs) {
              this.userNotifs = userNotifs;
         public int getNotificationsSize() {
              getUserNotificationsList();
              return notificationsSize;
         public void setNotificationsSize(int notificationsSize) {
              this.notificationsSize = notificationsSize;
         public String getColumn() {
              return column;
         public void setColumn(String column) {
              this.column = column;
         public String getSortDirection() {
              return sortDirection;
         public void setSortDirection(String sortDirection) {
              if(sortDirection != null && sortDirection.trim().length()!=0)
                   this.sortDirection = sortDirection;
         public String getPattern() {
              return pattern;
         public void setPattern(String pattern) {
              this.pattern = pattern;
         public String showInWorkList() {
              System.err.println("test");
              return "success1";
              //TODO Auto-generated method stub
         public String sort(){
              sort(column, sortDirection);
              return "success";
         @SuppressWarnings("unchecked")
         private void getUserNotificationsList()
              ArrayList<Notification> notificationsList = new ArrayList<Notification>();
              for(int i=0;i<20;i++)
                   Notification notif = new Notification();
                   notif.setCaseNB("122"+i);
                   notif.setCreateDT("12-12-2002");
                   notif.setSenderNM("testing1"+(i%3));
                   System.out.println(notif.getSenderNM());
                   notif.setSubjectTX("testing2"+(i%4));
                   System.out.println(notif.getSubjectTX());
                   notif.setPriorityCD("High");
                   notificationsList.add(notif);
    userNotifs.setNotificationsList(notificationsList);
              if(userNotifs.getNotificationsList()!=null)
                   this.setNotificationsSize(userNotifs.getNotificationsList().size());
    * <p>Return the <code>FacesContext</code> instance for the
    * current request.
    protected FacesContext context() {
    return (FacesContext.getCurrentInstance());
    protected void sort(final String column, final String direction) {
              java.util.Comparator comparator = new SortComparator(userNotifs.getNotificationsList(),column,direction,pattern);
              java.util.Collections.sort(userNotifs.getNotificationsList(), comparator);     
              if(direction.equalsIgnoreCase("asc"))
                   setSortDirection("desc");
              else
                   setSortDirection("asc");
    }

    Too less relevant information and too much irrelevant code.
    First of all, which JS error exactly are you getting? You as developer should know better that you shouldn't ignore errors. They contain helpful information about the cause of the problem and thus also how to solve it. Where exactly does the error come from? (view the generated HTML source). Which JSF implementation and version exactly are you using? Which webbrowser exactly are you using? Does it work in/with other/newer versions?

  • Javascript error in jsf page.

    Hi,
    I am trying to Do post form a script function in a jsf page. I am using the trh:script tag for adding the script. But when run it i am getting a lot of errors saying that the attributes cannot be recognised. I am trying to send a xml updated with some data after the click of a button to the server. Though its not showing any any errors when not run.
    Below is the code i am using :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ 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"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>
    <f:view>
    <trh:script text="
    var endpointURL = "http://localhost:7101/services/MobileManagerService";
    var xmlstring = '<?xml version="1.0"encoding="UTF-8"?>\
    <notifications>\
         <notification>\
              <id>1<\/id>\
                   <status>CLOSE<\/status>\               
              <\/notification>\
         <\/notifications>';
    var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
    var stautsXml = (new XMLSerializer()).serializeToString(xmlobject);
    alert(stautsXml);
    var http_request = false;
    function makePOSTRequest(method, url, parameters) {
    http_request = false;
    if(window.XMLHttpRequest) { // Mozilla, Safari,...
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
    // Set type accordingly to anticipated content type.
    http_request.overrideMimeType('text/xml');
    // http_request.overrideMimeType('text/html');
    } else if (window.ActiveXObject) { // IE
    try {
    http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
    if (!http_request) {
    alert('Cannot create XMLHttpRequest object');
    return false;
    http_request.onreadystatechange = alertContents;
    // http_request.open(method, url, true);
    if(method=='GET'){
    http_request.open(method, url + parameters, true);
    http_request.setRequestHeader("Content-type", "text/xml");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(null);
    if(method=='POST') {
    http_request.open(method, url, true);
    http_request.setRequestHeader("Content-type", "text/xml");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
    if(method=='PUT') {
    http_request.open(method, url, true);
    http_request.setRequestHeader("Content-type", "text/xml");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
    if(method=='DELETE') {
    http_request.open(method, url+parameters, true);
    http_request.setRequestHeader("Content-type", "text/xml");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(null);
    function alertContents() {
    if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    alert('Response received from server:\n'+http_request.responseText);
    result = http_request.responseText;
    // Turn < and > into &lt; and &gt; for displaying on the page.
    result = result.replace(/\<([^!])/g, '&lt;$1');
    result = result.replace(/([^-])\>/g, '$1&gt;');
    document.getElementById('serverresponse').innerHTML = result;
    } else {
    alert('There was a problem with the request.'
    +http_request.responseText +' '+http_request.status);
    document.getElementById('serverresponse').innerHTML = http_request.responseText;
    function postApproveForm() {
    var poststr = stautsXml ;
    alert('Sending XML to server:\n'+poststr);
    makePOSTRequest('POST', endpointURL , poststr);
    "/>
    <trh:html id="h2">
    <trh:head title="ApproveAlerts" id="h1">
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1252"/>
    <link type="text/css" rel="stylesheet" href="css/iPhone.css"/>
    </trh:head>
    <trh:body id="b1">
    <!-- <jsp:useBean id="IdBean" class="oracle.application.IdBean" scope="application"/> -->
    <af:messages id="m1"/>
    <trh:body styleClass="body" id="b2">
    <!-- <td><input type="button" name="Approve" value="Approve" onclick="javascript:approveAlert();"></td> -->
    <td>
    <input type="button" name="Approve" value="Approve" onclick="postApproveform();" </input>
    </td>
    <af:outputText id="ot1" value='"#{requestScope.myId}"'/>
    </trh:body>
    </trh:body>
    </trh:html>
    </f:view>
    Do i need to add some taglib or something to make it work ?
    Regards
    Sishant
    Edited by: user784337 on May 24, 2010 3:37 AM

    Because :
    Session.getAtrribute is java-code that can only run on the server
    and
    var y = session.getAttribute is javascript-code run on the client.

  • IE8 and javascript - Back/Forward button in Robohelp

    I am using Robohelp 7. I use the following script for my Back button - javascript:history.back(1);
    This works fine in FireFox and IE7, but not in IE8. Has anyone found a solution for javascript issues in IE8?
    Thanks,
    Deborah

    1) We (one of the programmers and I) tried this code in a "clean" IE8 environment and all three buttons worked:
    <
    html><
    head><
    title>Test Html</title></
    head><
    body>
    <input type='button' value="history.back(1)" onclick="javascript:history.back(1);" />
    <input type='button' value="history.go(-1)" onclick="javascript:history.go(-1);" />
    <input type='button' value="history.back()" onclick="javascript:history.back();" />
    </
    body>  
    </
    html>
    2) The button is in the Robohelp toolbar.
    3) This is the Robohelp code that generates the HTML:
    addButton("custom17587",BTN_TEXT|BTN_IMG,"Back","","javascript:history.back(1);  ","","",0,0,"backbuttonon.gif","backbuttonon.gif","","backbuttonon.gif","","");
    4) This is the HTML code that Robohelp generates for the Back button:
    The code that run is :
    <TBODY>
    <TR>
    <TD onmouseup="onBtnMouseUp(event, 4);" class=clsBtnNormal onmouseover="onBtnMouseOver(event, 4);" onmouseout="onBtnMouseOut(event, 4);" onmousedown="onBtnMouseDown(event, 4);" onclick="onBtnClick(event);return false;" vAlign=center noWrap align=middle><A id=btncustom17587 class=btncustom17587 onmouseover=cusOnMouseOver(0); title=Back onclick="cusOnClick(0);return false;" href="javascript:void(0);"><IMG border=0 alt=Back align=absMiddle src="http://localhost:8080/jserf/help/en_US/PortalHelp/backbuttonon.gif"> Back</A></TD>
    5) We tried all three options from #1 above in the Robohelp code (#4 above) and none of them worked in IE8.

  • How do Javascript refer to JSF IDs?

    Hi
    I have a JSF page and want to launch a java script (calendar pick date popup) from it.
    The java script pass in the HTML input ID (inputText0) of the input field to populate (result from date pick).
    But, I do not know the HTML input ID since JSF generate an ID (_id2:inputText0).
    Here is the JSF code:
    <h:form>
    <script type="text/javascript">
    var calDFrom = new CalendarPopup("testdiv1");
    calDFrom.showNavigationDropdowns();
    </script>
    <h:panelGrid columns="2">
    <h:panelGroup>
    <h:outputLabel id="outputLabel0" value="#{msg.repInFromDate}" for="inputText0" styleClass="fieldOutputHeaderLabel"/>
    </h:panelGroup>
    <h:panelGroup>
    <h:inputText id="inputText0" value="#{sessionActionListener.depotSales.fromDate}" required="true">
    <f:validator validatorId="dateValidator"/>
    </h:inputText>
    <h:graphicImage onklick="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" title="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" id="anchorCalDFrom" alt="jsf-sun" url="/images/calendar.gif" />
    </h:panelGroup>
    </h:panelGrid>
    </h:form>
    Here is an extract of the HTML rendederd by JSF:
    <tr class="detailDataTableRow">
    <td class="detailDataTableColumn"><label id="_id2:outputLabel0" for="_id2:inputText0" class="fieldOutputHeaderLabel">
    From Date</label></td>
    <td class="detailDataTableColumn"><input id="_id2:inputText0" type="text" name="_id2:inputText0" class="fieldInputDetailText" /><img id="_id2:anchorCalDFrom" src="/OrderSystem-ViewController-context-root/images/calendar.gif" alt="jsf-sun" onklick="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" title="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" /></td>
    </tr>
    How do I solve this problem?
    Henkie

    Assign an unique ID to the h:form and use document.getElementById() in JS. You can also make use of the 'this' reference in JS and then crawl through the parent form and/or the DOM tree.

  • Problem with JSF commandbutton !! help needed

    I have a command button like
    <h:commandButton id="submit" value="Submit" action="#{CheckForm.save}" />
    when i browse this, it is rendered as
    <input id="editSaveAppliance:submit" name="editSaveAppliance:submit" type="submit" value="Submit" onclick="clear_editSaveAppliance();" />
    where editSaveAppliance is my form name.
    I wonder why this onClick is attached to the button , even though I didnt say any onclick. Since this onclick event calls the clear_editSaveAppliance(); function which clears the value in the textbox... Y so?
    I want to call "CheckForm.save" on click of this button??
    can any body help me!

    Hi chandru,
    did you resolved the Command button problem?
    i am facing a similar problem.
    I am using RAD 6.0, when ever i define the listener code for a button it works fine but when i have a value change listener for my JSF Components such as selectOneMenu the action for the command button is not working.
    what may be the reason?
    please reply to this ASAP.

Maybe you are looking for