Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Closing Browser Tab..

Suchith ShivakumarApr 23 2015 — edited Apr 23 2015

Hello All:

I have a requirement, I need to close the browser tab upon action on the button. But before close the tab it should save the updated values.

I tried with below ways, but none of them worked.

1)using Java script

--Java script

          funtion closeWindow(){

         

          window.close();

          }

--Button

               <af:commandButton

                              text="Save"

                               id="cb5" action="#{MyBean.onSave}">

              <af:clientListener method="closeWindow" type="action"/>

            </af:commandButton>

--Bean

    public String onSave() {

      

        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

        OperationBinding operationBinding = bindings.getOperationBinding("Commit");

        operationBinding.execute();

         return null;

     }

In this way its closing the window, but it is unable to save the data.

2)calling java script programmatically   

--Java Script

funtion closeWindow(){

         

          window.close();

          }

--Button

               <af:commandButton

                              text="Save"

                               id="cb5" action="#{MyBean.onSave}">

            </af:commandButton>

--Bean

    public String onSave() {

      

        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

        OperationBinding operationBinding = bindings.getOperationBinding("Commit");

        operationBinding.execute();

       FacesContext facesContext = FacesContext.getCurrentInstance();

       org.apache.myfaces.trinidad.render.ExtendedRenderKitService service = org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);

       service.addScript(facesContext,closeWindow(); );

         return null;

     }

Please suggest me how this can be achieved..

Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2015
Added on Apr 23 2015
1 comment
604 views