Tuesday, December 29, 2009

Doing some work before showing Popup in ADF

Here is the way to do any processing before calling popup. First of all create a method in backing bean and assign this to action of "commandButton" or "commandLink". Sample signature for you method is as follows:

public void myMethod()
{
/**
* Place your processing logic here and then call showPoup method
**/
showPopup(popupId);
}

Signature of showPopup is:

public static void showPopup(String popupId)
{
FacesContext context = FacesContext.getCurrentInstance();

ExtendedRenderKitService extRenderKitSrvc =
Service.getRenderKitService(context, ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(context,
"AdfPage.PAGE.findComponent('" + popupId + "').show();");
}

3 comments:

i-Felix Andrew said...

Service class we have to import which package?
please give this info..

i-Felix Andrew said...

Hi I used the following procedure you have mentioned but it doesnt works,

can u plz correct my problem

In Jspx code




















In backing bean code
package view.backing;

import javax.faces.context.FacesContext;

import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.RichPanelWindow;
import oracle.adf.view.rich.component.rich.RichPopup;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

public class Untitled5 {
private RichForm f1;
private RichDocument d1;
private RichPopup p1;
private RichCommandButton cb1;
private RichPanelWindow pw1;
private RichCommandButton cb2;

public void setF1(RichForm f1) {
this.f1 = f1;
}

public RichForm getF1() {
return f1;
}

public void setD1(RichDocument d1) {
this.d1 = d1;
}

public RichDocument getD1() {
return d1;
}

public void setP1(RichPopup p1) {
this.p1 = p1;
}

public RichPopup getP1() {
return p1;
}

public void setCb1(RichCommandButton cb1) {
this.cb1 = cb1;
}

public RichCommandButton getCb1() {
return cb1;
}


public void setPw1(RichPanelWindow pw1) {
this.pw1 = pw1;
}

public RichPanelWindow getPw1() {
return pw1;
}

public void setCb2(RichCommandButton cb2) {
this.cb2 = cb2;
}

public RichCommandButton getCb2() {
return cb2;
}

public String cb2_action() {
// Add event code here...
FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService extRenderKitSrvc =
Service.getRenderKitService(context, ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(context,"AdfPage.PAGE.findComponent('" + p1 + "').show();");
return null;
}
}


Regards,
Felix

amer sohail said...

You have to import following classes:

- import org.apache.myfaces.trinidad.render.ExtendedRenderKitService
- javax.faces.context.FacesContext

Did you bind cb2_action with action of your control? I can't see your jsp code