How to call the backing bean method through javascript by closing window?

Hi all,
What I want to do is:
I open a new page by clicking <t:commanLink.../> from the first page. Then I close the new page. By closing the new page I will call a function in the backing bean such as myBean.doSomething() to do something. Such like:
<body onUnload=jsFunction()..../>
...

So far I understand, I should write following code
in my second page:
<html>
<head>
<script type="txet/javascript">
function jsFunction()
{>
ocument.forms[0].action="#{myBean.doSomething}";
document.forms[0].submit();
</scrip>
</head>
<body onunload="jsFunction()">
<ui:composition>
<h:form id="myForm">
<t:commandLink id="myLink" immediate="true"
action="#{myBean.doSomething}"
value=""></t:commandLink>
</h:form>
</ui:composition>
Is that right? I am not sure if I've the javascript
in the right position.I am sorry! That solution will not work. My Bad.
You can try this.
1) Have a invisible command button on your first page with the action attribute set to "#{myBean.doSomething}" as below
<t:commandButton style="width:0px;height:0px" id="myButton" immediate="true"
action="#{myBean.doSomething}"
  value=""></t:commandButton>2) Your JS onunload method on the second page should look like
<script type="txet/javascript">
   function jsFunction()
var buttonObject= window.parent.document.getElementById("formname:myButton");
buttonObject.click(); // This would help in submitting the first page
// to submit to the needed action method
</script>Karthik

Similar Messages

  • How to call the backing bean method through javascript

    Hi
    I have a command button associated with actionListener . Action Listener method associated with backing bean methods.
    I want to fire the event on command button and backing bean method should be invoked from javascript dynamically.
    can anybody help me asap

    JSF<h:form id="formId">
        <h:commandButton id="buttonId" value="submit" actionListener="#{myBean.action}" />
    </h:form>JSdocument.getElementById('formId:buttonId').click();

  • How to Call the Acrobat plug-in through javascript

    Is it possible to call the acrobat plug-in through javascript? Kindly help me with any samples.
    Thanks,
    Prabudass

    I have found the way to open the plugin menu "Documents-->OCR Text Recognition-->Recognize Text Using OCR" through javascript. Now i have to select the settings and set the values like the below options:
    1.Primary OCR Language : English (US)
    2.Pdf Output StyLe : Formatted Text & Graphics
    3.Down Sample Images : Lowest (600 dpi)
    which are listed in the "EDIT" menu of the "Recognize Text" form, and also to activate the "OK" button. Is it possible to do the above through Java Script. Please kindly provide any samples.
    Thanks,
    Prabudass

  • How to call a bean method through javascript?

    Hi,
    i want to call a bean method using the javascript.
    thansk in advance.

    hi
    i want to call a backing bean method thought javscript on the button click.
    i am inplementing addition of textbox at runtime.i wrote method and i am calling that on the button click.but the textbox is not created.
    the code is bleow
    public String doAction() {
         tryStuff1();
    return "samplejsf";
    public void tryStuff1()
    System.out.println("Enter the trystuff method");
         FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uIViewRoot = facesContext.getViewRoot();
    Application application = facesContext.getApplication();
    UIComponent formComp=uIViewRoot.findComponent("subbody:form1");
    HtmlPanelGrid grid= new HtmlPanelGrid();
    grid.setId("panelgrid2");
    grid.setColumns(2);
    grid.setBorder(2);
    //UIComponent panelGridComp=formComp.findComponent("subbody:panelgrid1");
    //UIComponent panelGroupComp=panelGridComp.findComponent("panelgroup2");
         HtmlOutputText output = new HtmlOutputText();
    output.setValue("dynamic jsf text2");
    System.out.println("hello output text2");
    output.setRendered(true);
    grid.getChildren().add(output);
    HtmlInputText input = new HtmlInputText();
    input.setSize(40);
    input.setValueBinding("value", (ValueBinding) application.createValueBinding("#{sample.text2}"));
    input.setRendered(true);
    grid.getChildren().add(input);
    System.out.println("hello output text1");
    grid.setRendered(true);
    formComp.getChildren().add(grid);
    System.out.println("hello output text3:");
    formComp.getRendersChildren();
    formComp.setRendered(true);
    public boolean getRendersChildren() {
         return true;
    jsp code is
    <h:form id="form1">
    <h:panelGrid columns="2" binding="#{sample.formElements}">
    </h:panelGrid>
    <h:panelGrid id="panelgrid1" columns="1">
    <h:panelGroup id="panelgroup1">
    <h:outputText value="hardcoded jsf text1"/>
    <h:inputText value="#{sample.text1}"/>
    </h:panelGroup>
    </h:panelGrid>
    <h:commandButton id="add" action="#{sample.doAction}" value="add" type="SUBMIT"/>
    </h:form>
    when i click on the button its going into the method and diaplying s.o.p but the text box is not updated to the page.
    why is it so.
    i thought there may be a problem in calling the method directly thru button. i want to try thru javascript calling the bean method.
    why is the page not updated.
    can u help me out
    thanks in advance
    sree

  • Calling a backing bean method after load of fragment in adf

    I needed to call a backing bean method after page load of fragment in adf.
    I used the method suggested in:
    https://community.oracle.com/message/11044570
    only difference is im giving the if clause as:
    if (refreshFlag == RegionBinding.RENDER_MODEL ) {
    instead of
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    It was working fine, but page was not getting refreshed so used the code as mentioned in example:
    public void refresh() {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              String refreshpage = facesContext.getViewRoot().getViewId();
              ViewHandler  viewHandler =facesContext.getApplication().getViewHandler();
              UIViewRoot viewroot =  viewHandler.createView( facesContext, refreshpage);
              viewroot.setViewId(refreshpage);
              facesContext.setViewRoot(viewroot);
    Now issue is once page is loaded and backing bean method is called, the refresh code refreshes the page and upon page load, refresh method is called again in recursive fashion.
    please advise what to do in such scenario?
    I tried to do selective refresh using some variable(also with static) but it does not help as page wont be refresh at all or page will keep refreshing recursively.

    Use clientListener on the page load event
    <af:document id=”d1″>
        <af:serverListener type=”onloadEvent”
                           method=”#{<managedbean name>.<method name>}”/>
        <af:clientListener method=”onLoadClient” type=”load”/>
        <af:resource type=”javascript”>
        function onLoadClient(event) {
          AdfCustomEvent.queue(event.getSource(),”onloadEvent”,{},false);
          return true;
        </af:resource>

  • How to call the form bean value on jsp withthe help of jstl tag

    hi
    all friends
    i am working in struts & i use jstl tag in jsp. i have one problem rise is how to call the form bean value in jsp page by using jstl tag.
    i now how to retrive the value through jsp:logic
    eg. <logic:empty name="userListForm" property="users">
    NO USER FOUND
    </logic:empty>
    see * userListForm mean formbaen name.
    * users means collection object.
    so how can i write above e.g in jstl

    You use the jstl core:if or core:choose combined with the EL:
    <c:if test="${empty users.userListForm}">
    NO USERS FOUND
    </c:if>I suggest you lookup the jsp expression language (EL) using google, it's very powerful.

  • Call a backing bean method using h:selectBooleanCheckbox of jsf on select

    I want to call a backing bean method using h:selectBooleanCheckbox of jsf on select and deselect.
    I cannot use af:selectBooleancheckBox of adf and h:selectBooleanCheckbox doesnot have the property of autosubmit="true"

    User,
    please don't duplicate your posts on this forum ({thread:id=2369739})
    If you don't get an answer right away it might be that there is some information missing or nobody had time to work on the issue. Pleas be patience...
    We all have other work to do to get our bills paid.
    If you can't wait open a support request with support.oracle.com
    Timo

  • How to call the screen in methods could u please explain

    hi,
    how to call the screen in methods could u please explain clearly with example

    HI ,
    CALL SCREEN - Call a screen
    Basic form
    CALL SCREEN scr.
    Addition:
    ... STARTING AT x1 y1 ... ENDING AT x2 y2
    Effect
    Calls the screen scr; scr is the number of a screen of the main program. You use SET SCREEN 0. or LEAVE SCREEN. to define the return from the CALL screen.
    Note
    Please consult Data Area and Modularization Unit Organization documentation as well.
    Addition
    ... STARTING AT x1 y1  ENDING AT x2 y2
    Effect
    The coordinates x1, y1 (start column and start line in the window) and x2, y2 (end column and end line in the window) define the size and position of the CALL screen ("top left - bottom right"). Besides these coordinates, you can also see the contents of the primary window, but cannot perform any action there.
    Note
    If "ENDING AT ..." is not specified, suitable values are substituted for x2 and y2, taking into account the size of the called screen.
    Exceptions
    Non-Catchable Exceptions
    Cause: No further screen level (call screen); the maximum number of nested screen levels is restricted to 50 at present.
    Runtime Error: DYNP_TOO_MANY_CALL_SCREENS
    THX

  • Calling a backing bean method by clicking on an image.

    I have several HtmlGraphicImage (h:graphicImage) objects on a page. I would like to be able to call a method inside the backing bean for the JSP page where the images are located when the user clicks on one of the images, and have a parameter sent to that method in the backing bean that will tell it which image was clicked on.
    How can this be done? Unlike buttons that have an action that gets listend to in the backing bean, HtmlGraphicImage objects do not have actions. I know that you can intercept clicks by an onClick Javascript method, but how can you call a mehtod in the backing bean using the Javascript onClick?
    For example, part of my JSP looks like this:
               <body style="background-color: rgb(255, 255, 255); -rave-layout: grid">
                    <h:form binding="#{InitialReport.form1}" id="form1">
                        <h:graphicImage binding="#{InitialReport.frontalImage}" height="204" id="frontalImage" style="left: 144px; top: 240px; position: absolute" width="242"/>
                        <h:graphicImage binding="#{InitialReport.profileImage}" height="198" id="profileImage" style="left: 432px; top: 240px; position: absolute" width="244"/>
                        <h:graphicImage binding="#{InitialReport.smileImage}" height="198" id="smileImage" style="left: 720px; top: 240px; position: absolute" width="244"/>If my backing bean (InitialReport.java) had a method that looked like this:
      public void setCurrentImage(String imageName)what would the javascript look like in order to send a name to setCurrentImage?
    Thanks!

    you can use the <h:button> with type='image'Thanks for the reply, but I cannot use that. The thing is, the images are read at run time from a database and are not present in the resources. The button's image only takes String file names, not URLs.
    There should be a way to do this using onClick.

  • Urgent: calling my backing bean method.

    I have a menu option implemented as a <h:commandLink> component and I want to call a MailBoxBean's method call checkMailBox(). This method checks some information on a database and returns a "success" String if everything is ok. The Bean is "configured" so that redirects to a mailbox.jsp if the "success" String is thje outcome. The information is shown on mailbox.jsp.
    The problem is that I can't get to the checkMailBox() method through the <h:commandLink> component although I have written the action attribute like this: <h:commanLink action="#{mailbox.checkMailBox}">.
    What's wrong with this?

    Thanks for answering so quickly. The fact is that I have my Bean declared and the navigation rule setted both in my faces-config.xml file.
    The firts problem I am having is that the menu option implemented with that <h:commandLink> component is not correctly rendered as I get some kind of javascript error, but I can see much more cause I'm using MS's Explorer.
    <h:commanLink action="#{mailbox.checkMailBox}" immediate="true">
    <h:outputText value="Check mailbox"/>
    </h:commandLink>
    Is these correct??

  • How to call different managed bean methods on a page template button

    Dear All,
    Use Case:
    I have a Page Template and inside this page template is a popup screen which is common to all my
    pages. My popup has OK and Cancel button only.
    My question is this, there are lots of pages that uses this template.
    How is it possible to invoke a managed bean methods dialoglistener when say for example the user clicks the OK button?
    One thing common among the pages is that they are included in some kind of a taskflow and I have configured
    a managedbean in a pageflowscope variable in each taskflow and I just wanted to pass the
    My Template
         - TaskFlow 1 (ManagedBean1.dialogListener)
         - TaskFlow 2 (ManagedBean2.dialogListener)
         - TaskFlow 3 (ManagedBean3.dialogListener)
    Each dialog listener does different things.     
    How to do this?
    JDEV 11G PS3
    Thanks

    Found my answer here... http://www.oracle.com/technetwork/developer-tools/adf/learnmore/79-global-template-button-strategy-360139.pdf
    Thanks!

  • How to call a void bean method in a jsp ?

    I want to call a bean method from the jsp page. The method is void i.e it returns nothing.
    Lets say the bean id is mybean and the method name is beanmethod( ). I want to know in what type of jsp tags should I put mybean.beanmethod( ). Using jsp expression <%= mybean.beanmethod( ) %> gives error and so does scriptlet <% mybean.beanmethod( ) %>
    Can someone help me out. Thanx.
    Arshad

    did you already implement this?
    <jsp:useBean id="mybean" class="yourPackage.YourBean scope="session"/>
    use ";" at the end:
    <% mybean.beanmethod(); %>

  • How to execute a backing-bean method before loading JSP Page?

    Hi everybody.
    Scene:
    An AdfForm, with
    -SelectChoice, referenced to a <list> of pageDef, which is referenced to an ADF BC.
    Goal:
    -Executing the query of the ADF BC before load the SelectChoice, to load the correct values.
    A good question to know:
    Exists any way to execute a method of backing before loading a JSP Page?
    Any similar to onload method of javascript. It could be fantastic.
    Thanks in advance,
    Jaime

    hi Jaime
    If I understand correctly, you are using the ADF Model for data binding.
    Because your goal is "Executing the query of the ADF BC ...", maybe you can also consider to refresh an executable in your Page Definition.
    See also "10.5.5 How to Use Refresh Correctly for InvokeAction and Iterator Bindings"
    at http://download.oracle.com/docs/html/B25947_01/bcdcpal005.htm#BJECHBHF
    It says "... You can use the Refresh property on iterator bindings and invokeAction executables in your page definition to control when each are evaluated during the ADF page lifecycle, either during the prepareModel phase, the prepareRender phase, or both. ...".
    Although you have posted your question in a structured way, which is a good thing, I think it would help to understand your question if you can explain how you determine "the correct values" for your list, what is varying?
    success
    Jan Vervecken

  • Somehow ejbCreate method of an Entity EJB is not inserting a record into the database. I'm using BMP and calling the Entity bean method from a servlet. I'm using NAS 4.0 sp5 on Win 2k.

    Also if I call the insert query from within the servlet it works fine. I have disabled global transactions. Am I missing something out ? Please
    any help would be greatly appreciated.

    May be your servlet is not able to lookup the EJB. You can use some print statements and see whether lookup ok or not.
    Just a guess.
    Plese get back, if any queries.
    Thanks,
    Rakesh.

  • Can I pass a param to the backing bean method?

    For example:
    <h:dataTable id="recentUpdateTable" var="video" value="#{VideoListBean.recentUpdated}">
    I want to pass a param to VideoListBean.getRecentUpdated(). The param can not be a request param
    How to do it?
    Thanks in advance.

    Maybe I should describe my question more clearly.
    For example:
    <h:dataTable id="foo1" var="list" value="#{test.list">
    <h:dataTable id="foo2" var="video" value="#{test.subList}">
    </h:dataTable>
    </h:dataTable>
    The subList is determined by a property of list but how can I pass the property to test.getSubList() ?
    Thank you!
    Message was edited by:
    zhlmmc

Maybe you are looking for

  • How do i create a playlist in itunes from my iphone 4s?

    how do i create a playlist in itunes from my iphone 4s?

  • Operation on ppt

    I am developing  a project operate ppt files , in C#,generate a ppt directly after processing the data.But when I am add the charts, i can only add the chart frame, I need to input data then the chart can be correct. How to add chart to excel with da

  • Problem removing hard drive HP Pavilion a1228x

    I removed the two screws on the side and the HD will move back and forth an inch or so, but I cannot pull it out.  I don't know what else is holding it in place or what I need to do to remove it. Any suggestions would be appreciated.

  • Switching to another desktop using Ctrl+number

    Hi All, I just updated to Yosemite. All seems to work fine but it seems I have lost one of my loving features for switching desktops. I normally have 9 desktops, and I have certain apps assigned to each desktop. To switch between desktops I always us

  • Report Server 9.0.2.x using sftp???

    Hi, is it possible to be able to use sftp with the 9.0.2.x reports server? i know there is a plugin for ftp does this work as well with sftp? or is there a plugin for that?