Defining Keystrokes on a JSF Page

Hi there and Happy Holidays. I have a question regarding keystrokes in JSF. On a conventional HTML page, a developer can use JavaScript to respond to keypress events. For example, I can have a button be clicked when a user presses F12 or Ctrl-C. I simply would like to achieve the same thing in JSF.
I am familiar with the accesskey property of certain JSF controls. For one thing, I cannot seem to figure out how those work. When I hit the key, nothing happens. For another, even if I could make it work, my understanding of the accesskey mechanism is that it only moves the focus to the control. It doesn't actually make the control work (e.g. click the button or the link). Again, I want the control to work upon keystrokes of my choosing rather than merely have the focus.
Any insight is appreciated. Thanks very much.
Neil

Well, the problem is that it might be a lot to ask users to go and configure some esoteric feature in their browsers just to accommodate accesskey. But thanks for letting me know about that capability.
As for your line of code, that is something I tried, but it didn't work. It actually makes sense since getElementById returns a DOM Element, which does not have a click method.
The answer is to retrieve the element as you say and then attach and initiate the event according to DOM2 as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
      <head>
        <title><ui:insert name="title">Default title</ui:insert></title>
        <script type="text/javascript">
            document.onkeydown = processKey;
            function processKey(e)
                var keyCode = window.event ? window.event.keyCode : e.keyCode;
                var mozillaClickEvent = null;
                if (keyCode == 122)
                       var submitLink = document.getElementById('myForm:submitLink');
                    if (document.createEvent)
                        mozillaClickEvent = document.createEvent("MouseEvents");
                        mozillaClickEvent.initEvent('click', true, false);
                        submitLink.dispatchEvent(mozillaClickEvent);
                        e.preventDefault();
                    else if (document.createEventObject)
                        submitLink.fireEvent('onclick');
                        window.event.keyCode = 0;
                        window.event.returnValue = false;
        </script>
      </head>
      <body>
        <form jsfc="h:form" id="myForm" action="success">
            Insert name <input type="text" jsfc="h:inputText" value="#{personBean.name}"/>
            <br/>
            <input jsfc="h:commandButton" type="submit" value="Submit" action="success" accesskey="t"/>
            <a jsfc="h:commandLink" accesskey="f" action="success"  id="submitLink" >Submit new</a>
        </form>
      </body>
</html> Thanks for your help.

Similar Messages

  • JSF pages to display content from external URLs

    Hi,
    Is it possible for a JSF page that uses ADF controls, and the PanelPage component to provide menuing, etc. to actually allow a HTML page (accessed via a URL to an external site/application) to be displayed in an area within the JSF page?
    For example, clicking a menu item to an external HTML page results in the page being displayed in a Frame or similar within the JSF page?
    I've tried the FrameBorderLayout control and Frame control to try to embed a Frame to display such a page via the target setting for a menu item, but that doesn't seem to work. At least not when within a PanelPage. It works within a basic JSP page.
    I would have thought it would be possible for a JSF application to incorporate HTML content from other sites/servers as if part of the application. Even if this meant defining "wrapper" pages of some sort to effectively link these into the JSF application as part of it's navigation rules.
    Or am I missing something?
    Gene

    Thanks,
    Yes, using an iFrame tag within a verbatim tag worked, allowing me to specify an external URL to a page which is then displayed at the location where I placed the verbatim tag. I need to investigate sizing/border settings, but at least I now seem to be able to embed such pages.
    This works.
    I tried jsp:include as well, but that only seems to allow relative URLs to pages that a part of the application. And using the c:import JSTL tag would import a page at an external URL, but didn't seem to position it where I wanted it.
    Gene

  • How do mathematical functions in a table invoked in jsf page

    hi i need detail about how can i do mathematical functions for data in table in jsf page using adf bc. for example in my table(sales) i give product id,name,unit price, quantity then i want to calculate product of quantity and unit price in a table automatically and store in total amount column

    Hi,
    John suggestion would work. Another option is to define it in EL using #{row.quantity * row.unitPrice} as the outputText value. Then add a numberConverter to the outputText using type="currency". The best option, imho, is to define the totalAmount attribute on the VO and implement the product there. However, keep the converter on the inputText and don't use the display hints on the VO.
    Regards,
    ~ Simon

  • Using an LOV populated by AJAX in JSF page (Jdev 10.1.3.3)

    Hello
    I have a field on the JSF page which is associated with a ajax based LOV. The problem is that when we select a value and 'submit' the page, the value passed to the bean is null. I thought that was because we didn't have the bindings correct. However when define the bindings I get errors during run time.
    My code snippet looks as follows:
    <h:selectOneMenu id="series"
    styleClass="textfield"
    style="width:60px;"
    onchange="getLocation();"
    onfocus="getLocation();"
    binding="#{mydata.series}"
    immediate="true" />
    Get Locations
    Is there anyway I can do this without using ADF?.
    The error message I get is:
    javax.servlet.jsp.JspException: Conversion Error setting value ''{0}'' for ''{1}''.      at com.sun.faces.taglib.html_basic.SelectOneMenuTag.doEndTag(SelectOneMenuTag.java:515)     at pages.dataEntry._jspService(_dataEntry.java:129)     [pages/dataEntry.jsp]
    Any workarounds/tips appreciated !!.
    Thanks and regards
    Prakash

    Hi,
    ADF does not have anything to do with it because its only an optional binding layer to use with JSF. My thinking is that your "Ajax" list (though I don't see Ajax in your code snippet) doesn't update the field so the component becomes aware of this change.
    Frank

  • Scripting in JSF pages

    Hey,
    I have 2 JSF pages: container.jsp and sub.jsp,
    container.jsp loads sub.jsp in a dynamic call like this:
    <jsp:include page='<%= pageToLoad %>' />Inside sub.jsp, I have a parameter defined for a commandLink tag:
    <h:commandLink ...>
      <f:param name="param1" value="<%= value %>" />
    </h:commandLink>Problem:
    - container.jsp fails to load and returns an error because it seems that the JSF tags within sub.jsp have execution priority over the script code (which is read literally and not executed).
    - if I remove the script and hardcode the value, it works fine
    - if I write the same code inside container.jsp, it works fine as well
    Question:
    How can I overcome this problem? Is there any alternative way for reaching the same outcome?
    Thanks,
    Mobal

    I ever wrote an article about that: http://balusc.blogspot.com/2007/01/dynamic-jsf-subviews.html

  • Invoke secured WS from ADF JSF Page

    Hello,
    How can I invoke secured Web Service from simple adf jsf page?? Service is secured by wss_username_token_service_policy.
    I'll be glad if somebody could give me some tutorial how to build this page. I mean inputs for username and password.
    Best regards,
    MK

    Hi,
    I've read your article: http://www.oracle.com/technology/products/jdev/howtos/1013/protectedws/access_protected_web_services_from_adf.htm I added to the Model - Web Service Data control and as a service give a link to my composite application deployed on soa_server (http://localhost:8001/soa-infra/services/default/registerMyPassComposite/registerMyPassWebService?WSDL). When i click on Define Web Service security I only have a window to add policies and there is no wizard steps as you shown i your article Figure 9. I cannot chose Authentication type but I can only define policies for my dataControl.
    How to resolve it?

  • JSF Page Load

    Is there such thing as a JSF Init Page Load? the same thing that .net has with Page_Load? How do i init the code behind bean?

    @sdechgan
    I had the same problem. What you can do is the following:
    in your Bean you need all your request parameters as properties with getter and setter.
    additionally add a boolan prepare property. Set this to false at the beans constructor : this.prepare = false;
    in your faces config define your bean this way :
    <managed-bean>
            <managed-bean-name>myBean</managed-bean-name>
            <managed-bean-class>org.you.package.beans.myBean</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                 <property-name>requestParam01</property-name>
                 <value>#{param.requestParam01}</value>
             </managed-property>
             <managed-property>
                 <property-name>requestParam02</property-name>
                 <value>#{param.requestParam02}</value>
             </managed-property>
             <managed-property>
                 <property-name>prepare</property-name>
                 <value>true</value>
             </managed-property>
        </managed-bean>in your view add such a single line at the beginning ( right under <f:view... > )
    <h:panelGroup rendered="#{myBean.prepare}" />now, tomcat will execute myBean.getPrepare( )
    this method should look like this :
    public boolean getPrepare()
              if (prepare)
                   //do what you want with your request params. they are already set at this point !
              prepare = false;
             return prepare;
         }after loading the view once, the getPrepare Method is executed and the prepare property is set to false.
    I need that, because getPrepare is loaded at any ajax page reload, too. ( I'm using icefaces )
    access your jsf page with : http:localhost:8080/whatever/myPage.iface?requestParam01=hello&requestParam02=World

  • Jsf pages extension

    Hi!
    I have one question: JSF has defined any extension for the pages like struts has .jsp? .jsf or .faces, or something like that! I can put what I want? Like .asdfsfd?
    Thank you!!!

    As for any other Servlet, you can just define it in the url-pattern of the servlet mapping of the FacesServlet in the web.xml.

  • How to run and JSF page from Bea Weblogic 8.1

    Hi, I am new to JSF . Can anybody help me that how can i access a JSF page from Bea Weblogic 8.1. How can deploy. What libraries and files are needed and where to put these required .jar or library files. I just wrote a single page and now i am not able to run it . Any help would be highly appreciated.I am looking forward for your kind replies.Thank you.
    Regards,
    Waqar

    You need to package your application into the standard .war format. Make sure jsf-api.jar and jsf-impl.jar are placed in WEB-INF/lib, your faces-config.xml is in WEB-INF, and your tld files are defined appropriately. Once you have your .war file, deploy it to your servers applications directory or use the console for deployment.
    You should not have any problems if everything is packaged correctly. I am successfully using WebLogic Server 8.1 with my JSF-based web app.

  • How do I pass input values from a html page to a jsf page

    hi,
    In my project,for front view we have used html pages.how can I get input values from that html page into my jsf page.for back end purpose we have used EJB3.0
    how can I write jsf managed bean for accessing these entities.we have used session facade design pattern and the IDE is netbeans5.5.
    pls,help me,very urgent
    thanx in advance

    Simplest way is to rewrite html page into jsf page.
    You can use session bean in your managed bean like this:
    import javax.naming.Context;
    import javax.naming.InitialContext;
    public class ManagedBean {
    private Context  ctx;
    private Object res;
    // session bean interface
    private Service service;
              public ManagedBean() {
                try{
                     ctx = new InitialContext();
                     res = ctx.lookup("Service");
                     service = (Service) res;
               catch(Exeption e){
    }Message was edited by:
    m00dy

  • How to get values from a query string in URL in a jsf page?

    if i have a url, http://my.com/?name=john+smith, how do i get the values from that url in a jsf page and then pass those values to a servlet?
    i know how to do that in jsp using "request.getParamter("name")" and save it in a bean and then forward to a servlet. But what about in jsf?

    Hello,
    Try this:
    Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    String name = (String) requestMap.get("name");If isn't worked one of these methods probably will solve your problem.
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap();hth.

  • How to Open an Oracle Report From a JSF Page

    Hi there,
    I would be really grateful if anyone would find me a solution to the following scenario:
    In my company, we have a project where we have to convert Oracle Forms and Reports to Java Web Application. The conversion of forms is being done thourgh JSF/ADF technology but how can i open an Oracle Report from a JSF page after supplying it with parameters ? Or i have to do some type of conversion before ?
    Once again i would be thankfull for your replies.

    Tapash,
    Thanks for reponding.
    Here is the URL I am currently using :
    https://gccss.glendale.edu:8001/dev60cgi/rwcgi60?server=rep60_crp3+userid=apps/pswd@crp3+report=/u07/oracle/crp3appl/gcccus/11.5.0/reports/US/GCC_ACCRUAL_BAL_0505.rdf+desformat=html+paramform=yes+destype=cache+p_accesscode=""
    The p_accesscode is the parameter I need to pass to the Oracle report.
    Currently, when I click the button, it invokes the above URL and takes me to the parameter form of the Oracle report and when I enter the Username, it runs the report and displays the desired output. But, what I need to achieve is, to pass the current user who has logged in behind the scene and to get rid of the parameter screen totally. Is this doable ? If yes, please help me !!!
    Thanks
    Hilal

  • How-to get attributes from one JSF page redirected to another?

    How do I send information from one JSF page when the navigation rule redirects it to another?
    When JSF navigation does a forward I can use request.setAttribute() in the from-page and then use request.getAttribute() in the to-page, but this doesn't work with <redirect/>.
    Regards,
    Al Malin

    The process scope in ADF Faces solves this. See:
    http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3/state/content/navId.4/navSetId._/vtTopicFile.adffacesguide%7Cdevguide%7CcommunicatingBetweenPages%7Ehtml/

  • How to Use another JSF page that I load by XMLHttpRequest?

    Hi everyone, I'm a newbie of JSF and curisous about how to load page content seperately by AJAX.
    I saw example of Java Blue Print. It's load some data to use in page. What I want is to load another JSF page when click a link or button, (Like include another page). And work with functions privoided by loaded JSF Page.
    My example is, In a main page. I request a JSF page and set it into a div layer.
    var requestURL = "/admin/customer/customer-list-body.faces";
    var content = postDataWithoutContent(requestURL);     divContent.innerHTML = content;     
    All JSF components are required under <f:view>, thus action of form is set as "action='"/admin/customer/customer-list-body.faces'"
    But my page is main.jsp. Each time I click command button in customer-list-body.faces, the url will change to customer-list-body.faces, I want to request and hold in main.jsp.
    What can I do then? Any advices?

    Hi,
    the list doesn't seem to be your problem. You need to track down the illegal argument exception. Once you have that sorted out, expose the method on the AM so it gets shown as a method binding. The return values then could be picked up in a managed bean to create the select Item list
    Frank

  • How can I put an output stream (HTML) from a remote process on my JSF page

    Hello,
    I've a question if someone could help.
    I have a jsf application that need to execute some remote stuff on a different process (it is a SAS application). This remote process produces in output an html table that I want to display in my jsf page.
    So I use a socket SAS class for setting up a server socket in a separate thread. The primary use of this class is to setup a socket listener, submit a command to a remote process (such as SAS) to generate a data stream (such as HTML or graphics) back to the listening socket, and then write the contents of the stream back to the servlet stream.
    Now the problem is that I loose my jsf page at all. I need a suggestion if some one would help, to understand how can I use this html datastream without writing on my Servlet output stream.
    Thank you in advance
    A.
    Just if you want to look at the details .....
    // Create the remote model
    com.sas.sasserver.submit.SubmitInterface si =
    (com.sas.sasserver.submit.SubmitInterface)
    rocf.newInstance(com.sas.sasserver.submit.SubmitInterface.class, connection);
    // Create a work dataset
    String stmt = "data work.foo;input field1 $ field2 $;cards;\na b\nc d\n;run;";
    si.setProgramText(stmt);
    // Setup our socket listener and get the port that it is bound to
    com.sas.servlet.util.SocketListener socket =
    new com.sas.servlet.util.SocketListener();
    int port = socket.setup();
    socket.start();
    // Get the localhost name
    String localhost = (java.net.InetAddress.getLocalHost()).getHostAddress();
    stmt = "filename sock SOCKET '" + localhost + ":" + port + "';";
    si.setProgramText(stmt);
    // Setup the ods options
    stmt = "ods html body=sock style=brick;";
    si.setProgramText(stmt);
    // Print the dataset
    stmt = "proc print data=work.foo;run;";
    si.setProgramText(stmt);
    // Close
    stmt = "ods html close;run;";
    si.setProgramText(stmt);
    // get my output stream
    context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
    ServletOutputStream out = response.getOutputStream();
    // Write the data from the socket to the response
    socket.write(out);
    // Close the socket listener
    socket.close();

    The system exec function is on the Communication palette. Its for executing system commands. On my Win2K system, the help for FTP is:
    "Ftp
    Transfers files to and from a computer running an FTP server service (sometimes called a daemon). Ftp can be used interactively. Click ftp commands in the Related Topics list for a description of available ftp subcommands. This command is available only if the TCP/IP protocol has been installed. Ftp is a service, that, once started, creates a sub-environment in which you can use ftp commands, and from which you can return to the Windows 2000 command prompt by typing the quit subcommand. When the ftp sub-environment is running, it is indicated by the ftp command prompt.
    ftp [-v] [-n] [-i] [-d] [-g]
    [-s:filename] [-a] [-w:windowsize] [computer]
    Parameters
    -v
    Suppresses display of remote server responses.
    -n
    Suppresses autologin upon initial connection.
    -i
    Turns off interactive prompting during multiple file transfers.
    -d
    Enables debugging, displaying all ftp commands passed between the client and server.
    -g
    Disables file name globbing, which permits the use of wildcard characters (* and ?) in local file and path names. (See the glob command in the online Command Reference.)
    -s:filename
    Specifies a text file containing ftp commands; the commands automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch instead of redirection (>).
    -a
    Use any local interface when binding data connection.
    -w:windowsize
    Overrides the default transfer buffer size of 4096.
    computer
    Specifies the computer name or IP address of the remote computer to connect to. The computer, if specified, must be the last paramete
    r on the line."
    I use tftp all of the time to transfer files in a similar manner. Test the transfer from the Windows command line and copy it into a VI. Pass the command line to system exec and wait until it's done.

Maybe you are looking for

  • Unable to Verify Apple ID

    Just got an iphone 4s and during setup i created an apple ID. At the end i received an email to verify, when I click on verify and enter the password it gives me this error: This email address is already in use or you may already have an Apple ID ass

  • Long time for activation of integration models

    Hi Experts, I am getting error that I am unable to trace the actual reason from system log or the QRFC monitor (APO inbound Q) Refresh, unlock, reset etc does not change the status. Most LUWu2019s are executed but for some LUWu2019s are taking longer

  • Plot line, bar and pie chart

    Anyone can let me know where can i learn or tutorial on how to plot line, bar and pie chart by using java2D... (no third-party software).... thanks in advance.

  • How to put a Flash movie on IWeb pages

    I am trying to find out how I can put flash movies on a website designed in IWeb. The .mov files are large and therefore load very slowly (and are also able to be downloaded by anyone with QT Pro I think). Does anyone know how to put flash videos (an

  • DBACOCKPIT saptools

    Dear Experts, In our organization there is no Database Administrator.I only the BASIS administrator. Now i am facing one issue.In DBACOCKPIT when we going to configure any thing it is showing "Repair Data Collector". Instructions from SAP support tea