Adf faces: execute bean method after table is loaded

Hi,
How can I execute a method after an adf table is rendered on the page?
This is what I want to do:
I have a master/detail:
- the master part contains a list of materials
- the details contains a list of customers and volumes depending on the selected material.
I tried to add totals on the details table:
- I created an output text in the footer-facet of the colums containing volumes
- I created a binding of the detail table to a CoreTable.
- I created a method in a managed bean related to this CoreTable binding, so I can browse to all rows in the table and calculate the sum.
- I then set the value of the output text to the total calculated in the managed bean.
the problem is that I don't know how to execute the calculate procedure after the data in the detail table exists.
What I tried:
- call the calculate procedure in the setCoreTable method. --> at this point, there is no data in the table and this results in a nullPointerException when the pages is loaded.
- call the calculate procedure on the valueChangeListener of the material list --> this doesn't work because totals are calculated for the previous details set.
- I tried to add the call in one of the table listeners but I cannot find a listener that is executed after data is loaded in the table...
for testing purpose only, I added a button: calculateTotals that calculates the totals. This works correctly.

Hi,
if you use page fragments exposed in an ADF region, you have two options I see
1. Use a method call activity to call the managed bean
2. Use a hidden UI component that references the setter/getter exposed in a managed bean and just use this as an indication for the page fragment being loaded
Keragala

Similar Messages

  • 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 execute a method after page Load?

    My question is very similar to what was discussed in following thread:
    How to execute a method after page Load?
    My requirement is that I want to run a method in backing bean of a page, immediately after the page gets loaded. In that method I want to invoke one of the method action included in the pagedef of this page, conditionally.
    I tried using the approach given in the above thread, i.e to use <f:view afterPhase="#{backing_security.setPermPriv}">, but the problem is that our page is not using 'f:view' , so I explicitly added one f:view with afterPhase property set , but it is not working, page it self is not getting loaded, it is throwing the error:
    Root cause of ServletException.
    java.lang.IllegalStateException: <f:view> was not present on this page; tag [email protected]e8encountered without an <f:view> being processed.
         at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:108)
         at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:733)
         at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
         at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:71)
         at oracle.adfinternal.view.faces.taglib.UIXQueryTag.doStartTag(UIXQueryTag.java:41)
         at oracle.adfinternal.view.faces.unified.taglib.UnifiedQueryTag.doStartTag(UnifiedQueryTag.java:51)
         at oracle.jsp.runtime.tree.OracleJspBodyTagNode.executeHandler(OracleJspBodyTagNode.java:50)
         at oracle.jsp.runtime.tree.OracleJspCustomTagNode.execute(OracleJspCustomTagNode.java:262)
         at oracle.jsp.runtime.tree.OracleJspNode.execute(OracleJspNode.java:89)
         at oracle.jsp.runtimev2.ShortCutServlet._jspService(ShortCutServlet.java:89)
         at oracle.jsp.runtime.OracleJspBase.service(OracleJspBase.java:29)
         at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:665)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:387)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:822)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:746)
    Please help to resolve this issue, or am I doing anything wrong?

    Hi,
    I assume that your view is a page fragment and here - indeed - the f:view tag cannot be used. If you use ADF then one option would be to use a custom RegionController on the binding layer to listen for the render phase to invoke the method. Another option would be to use a hidden field (output text set to display="false" and have this component value referencing a managed bean property. The managed bean property's getter method can now be used to invoke the method you want to run upon view rendering
    Frank

  • How to call a javascript method after table load on JSFF Fragment load?

    Hello,
    The usecase is to invoke a javascript method after table is done loading (fetching data) when user lands to a JSFF fragment. With JSPX pages I can achieve that by using PagePhaseListener. I have tried with RegionController as follows, and the problem i face is that I cannot prevent multiple calls to the Javascript call when user presses a tab or button in a screen, or changes drop-down value with autosubmit on.
    import javax.faces.context.FacesContext;
    import oracle.adf.model.RegionBinding;
    import oracle.adf.model.RegionContext;
    import oracle.adf.model.RegionController;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class MyListener implements RegionController{
    public MyListener() {
    super();
    @Override
    public boolean refreshRegion(RegionContext regionContext) {
    int refreshFlag = regionContext.getRefreshFlag();
    System.out.println("Render flag is: "+refreshFlag);
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    initializeMethod();
    regionContext.getRegionBinding().refresh(refreshFlag);
    return false;
    public boolean validateRegion(RegionContext regionContext) {
    regionContext.getRegionBinding().validate();
    return false;
    public boolean isRegionViewable(RegionContext regionContext) {
    return regionContext.getRegionBinding().isViewable();
    public void initializeMethod() {
    FacesContext f = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(f, ExtendedRenderKitService.class);
    service.addScript(f, "myJSFunction();");
    @Override
    public String getName() {
    return null;
    I need the javascript to be called only once after the table is done loading when user lands to a fragment (jsff).
    Any ideas appreciated?
    JDeveloper version is 11.1.1.5.0
    Thank you.
    Valon
    Edited by: Valon on Apr 11, 2013 3:10 PM

    One of the requirements is to compare every row with the next row and highlight the changes. There are other requirements as well where JavaScript solution is used.
    The question remains the same. Is it doable or not without changing the solution from JavaScript solution to server-side solution ? Can we call a JavaScript only once when the user lands to a jsff fragment ?
    Hope that is clear.
    Thanks.
    Valon

  • How to execute the method of a class loaded

    Hi,
    I have to execute the method of com.common.helper.EANCRatingHelper" + version
    version may be 1,2, etc
    if version = 1 the class is com.common.helper.EANCRatingHelper1;
    Iam able to load the class using following code.But iam unable to execute the method of the above class
    Can anybody help me how to execute the method of the class loaded.
    Following is the code
    String version = getHelperClassVersion(requestDate);
    String helperClass = "com.redroller.common.carriers.eanc.helper.EANCRatingHelper" + version;
    Class eancRatingHelper = Class.forName(helperClass);
    eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.
    Thanks

    eancRatingHelper.newInstance();Ok, that creates an instance, but you just threw it away. You need to save the return of that.
    Object helper = eancRatingHelper.newInstance();
    eancRatingHelper.saveRating(); This is not executing throwing an error no method.Of course. eancRatingHelper is a Class object, not an instance of your EANCRatingHelper object. The "helper" object I created above is (though it is only of type "Object" right now) -- you have to cast it to the desired class, and then call the method on that.
    Hopefully EANCRatingHelper1 and 2 share a common interface, or you're up the creek.

  • Accessing facade bean in ADF Faces managed bean

    Hello
    I am trying to display data from a database on a page using ADF Faces. I am using a Web Application [JSF, EJB] template in JDeveloper with the model project using JPA entities with a session facade bean to manage the entities (as described here: http://www.oracle.com/technology/obe/obe1013jdev/10131/ejb_and_jpa/master-detail_pagewith_ejb.htm ).
    What I have tried to do is to set up a managed session bean in the ViewController project that is referenced by a faces page. The managed bean is supposed to, on creation, load data from the database into managed properties which are then displayed on the faces page using EL references. I want all JPA management to go through the facade, and thus I want to inject the facade bean into the managed bean using @EJB notation. However, the injection does not work, and all I get is a NullPointerException when trying to access the injected facade in the managed bean.
    I have also tried instantiating the facade bean in the managed bean's constructor manually, but when I try to call a method on the facade, I get another NullPointerException, this time from the entity manager which obviously is not injected into the facade bean.
    What is strange is that the facade bean works perfectly when I use the datacontrols generated from the facade bean, as described in the tutorial (no exception from the entity manager).
    I have searched high and low for a solution to this, and from what I can read, it should be possible to do what I want (see for example https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html and http://luxlog.wordpress.com/2007/12/15/basic-example-web-app-with-glassfish-netbeans-60-jsf-and-ejb3/ ). I found someone mentioning that dependency injection in the web container OC4J was added after a given version, and that web.xml needs to be upgraded to version 2.5, which I have done but did not solve anything.
    Is this not possible in JDeveloper/OC4J at all? Is there any other way to access the facade session bean in managed beans?

    Hi,
    for resource injection you need JDeveloper 11. Here the EJB annotation works to inject the resource. If you want to do similar in 10.1.3 then you need to do a JNI lookup in the managed bean (under the shelves ADF does the same)
    Frank

  • JDeveloper 10g, ADF Faces & BC: setVar method on CoreTable is not working

    Hi all,
    I am in the process of creating a custom tag library for our organization. I seem to be having problems with the setVar method on the CoreTable component. I created a simple reproducible example using the scott/tiger schema. Within my tabletest.jsp, I have a af:table which was created via dragging from the datacontrol pallet. Next, I add my custom tag and set the same value attribute. When I run the page, #{row.Deptno} does not evaluate to anything! However, I know that the value is set properly due to the same number of rows appearing within my custom table tag.
    Suggestions are appreciated.
    thanks,
    Wes
    Here is the screen shot of my example:
    http://www.flickr.com/photos/54652784@N03/5062690216
    jsp code:
    <!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/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
    <%@ taglib uri="http://acme.customtag" prefix="customtag"%>
    <f:view>
    <afh:html>
    <afh:head title="tabletest">
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1252"/>
    </afh:head>
    <afh:body>
    <af:messages/>
    <h:form>
    <af:outputText value="below is the adf table"/>
    <af:table value="#{bindings.ViewObj1.collectionModel}" var="row">
    <af:column sortProperty="Deptno" sortable="false"
    headerText="#{bindings.ViewObj1.labels.Deptno}">
    <af:outputText value="#{row.Deptno}"/>
    </af:column>
    <af:column sortProperty="Dname" sortable="false"
    headerText="#{bindings.ViewObj1.labels.Dname}">
    <af:outputText value="#{row.Dname}"/>
    </af:column>
    </af:table>
    <af:objectSpacer width="10" height="50"/>
    <af:outputText value="Below is the custom table"/>
    </h:form>
    <customtag:customtable value="#{bindings.ViewObj1.collectionModel}"
    disabled="false"/>
    </afh:body>
    </afh:html>
    </f:view>
    CustomTable.java code:
    package customtag;
    import java.io.IOException;
    import javax.faces.application.Application;
    import javax.faces.component.UIComponentBase;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import oracle.adf.view.faces.component.core.data.CoreColumn;
    import oracle.adf.view.faces.component.core.data.CoreTable;
    import oracle.adf.view.faces.component.core.output.CoreOutputText;
    public class CustomTable extends UIComponentBase {
    public static final String COMPONENT_TYPE = "customtag.customtable";
    public static final String RENDERER_TYPE = null;
    private CoreTable table = new CoreTable();
    public CustomTable() {
    public void encodeChildren(FacesContext context) throws IOException {
    // Encode the top most component
    Application apps = context.getApplication();
    table.setVar("row");
    Object value = getAttributes().get("value");
    CoreColumn column = new CoreColumn();
    CoreOutputText cout = new CoreOutputText();
    if (value != null) {
    table.setValue(value);
    ValueBinding rowValueBinding =
    apps.createValueBinding("#{row.Deptno}");
    Object rowValue = resolveExpression("#{row.Deptno}");
    if (rowValue != null) {
    System.out.println("rowValue is reconized. " + rowValue);
    cout.setValue(rowValue);
    } else if (rowValueBinding.getValue(context) != null) {
    System.out.println("rowValueBinding is reconized." +
    rowValueBinding.getValue(context));
    cout.setValueBinding("Value", rowValueBinding);
    } else {
    System.out.println("row is not reconized.");
    cout.setValue("this is a hard coded row attribute value");
    column.getChildren().add(cout);
    table.getChildren().add(column);
    table.encodeAll(context);
    public static Object resolveExpression(String expression) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    Application app = ctx.getApplication();
    ValueBinding bind = app.createValueBinding(expression);
    return bind.getValue(ctx);
    public boolean getRendersChildren() {
    return true;
    public String getFamily() {
    return COMPONENT_TYPE;
    }

    Hi,
    you don't mention a JDeveloper version. If you are not on a recent version, can you try one. If it reproduces, please provide steps required for a reproducible test case
    Frank

  • [EJB3 - ADF Faces] entity bean design

    Hello,
    I have an existant application that use database view (very complex) to retrieve and display values from some tables.
    I have to reproduce the same thing with EJB3 ans ADF Faces in a web application.
    What is for you the best way to design entities beans ?
    1. Create some buisness objects (entity beans) and feed them with a query thru the database view ?
    2. Create a unique entity bean with only attributes who are used by the db view ?
    In this case, the entity bean will be used only for this query.
    3. ?
    I think the best solution is the first one.
    But in this case, how to display the result of the query in an ADF Faces table?
    With the 2nd solution the query returns a list of object which will be used by the adf table. That would be much easier.
    Thanks for your help.

    The popup dialog is used for looking up a value of fields on the form. I have fields "location id" and "sub location id", the popup has cascading drop down lists where I choose which ones I want, then return those values from the popup and display the selection in readonly text inputs. Other inputs also exist on the form. Together they all make the input parameters to the session facade's query.

  • ADF Faces: state saving method questions

    Please, could somebody elaborate implementation of state saving in ADF Faces? What specially interests me is a way on which it is improved in comparison with RI. Will be current implementation further improved regarding size of state which is stored in session or on client?
    Further, is it possible to make a read only page stateless? I tried naively to implement restore view phase listener which sets up transient property of view root to true. Page was rendered fine, but when I try to post something from that page NullPointerException was thrown from UIXComponentBase._getRendererImpl() method.
    Tnx

    Could you elaborate on the back button support?
    I'm trying to do something very simple right now with two JSF pages using ADF BC/Faces. One page is a simple table allowing the user to select a row. The second page allows the user to view details on the selected row. This is view only at this point. I've found however, that if I select a row and go to the detail page and then hit the back button to return to the first page and then select another row and attempt to go to the detail page I get an error message like so:
    1. validation - JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-35007: Row currency has changed since the user interface was rendered. The expected row key was oracle.jbo.Key[1246992000 ]
    2. validation - JBO-35007: Row currency has changed since the user interface was rendered. The expected row key was oracle.jbo.Key[1246992000 ]
    I'm at a loss as to how to resolve this issue.
    Thanks,
    Corey

  • Trigger a backing bean method after selection on select one choice

    Hi all,
    I'm new to Jdeveloper 11g, and I'm trying to trigger a method after the user makes a selection on a "select one choice" (JSF page).
    I have a method (backing bean) that reads the selection and executes a procedure that retrieves some data and fills that on Input Text A and B, unfortunately this is implemented using an af: button and I would like this method to trigger automatically after the user makes the selection without clicking the button. Can you help me?
    Thanks,
    Mike.

    Thanks for your response, your suggestion does what I asked, it fires the procedure but now the code does not work, for some reason the variable "clientListIndex" is null, but if I place the code in a method associated with a button it works. Any suggestion?
    public void onChangeCliente(ValueChangeEvent valueChangeEvent) throws SQLException {
    if(valueChangeEvent.getNewValue() != null){  
    DCBindingContainer dcBinding =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCControlBinding listControlBinding =
    dcBinding.findCtrlBinding("NameSourceList");
    FacesCtrlListBinding listBinding = (FacesCtrlListBinding)listControlBinding;
    if (clientListIndex != null){
    Row row = listBinding.getRowAtRangeIndex(Integer.valueOf(clienteListIndex));
    String enquiryListCode = row.getAttribute("Cvecliente").toString();
    else{
    System.out.println("null value");
    }

  • ADF Faces: Range Navigation in af:table

    I shortly migrated my application to ADF Faces EA13.
    Now when I use range navigation in a <af:table> there appeares an option in the dropdown list, that was not there in EA11: "Show All <number of rows in the table>".
    Is there a possibility to disable this new feature? I don't want the user to select "Show All" when there are thousands of rows in the corresponding database table.
    Regards,
    Mareike

    We are working on skinning APIs to allow customization of the look-and-feel of our components.
    As for customization of individual features like this, there's always a tension between simplicity and complexity - more hooks to tweak behavior does improve flexibility in the here-and-now, but it increases complexity, makes testing the components that much harder, and also locks in API decisions that often in the long run actually decreases flexibility. I'm not saying "no" to this request, which is reasonable, just trying to give you some insight into why we don't just by default make every last thing modifiable up front.

  • ADF Faces - filtering a selectOneChoice after select from another

    Hi,
    I'm new to ADF faces and I've been experimenting with developing applications using Jdeveloper 10.1.3 and ADF faces. I've run into a little problem.
    I have two selectOnceChoice fields on a page (division and dept.) When user selects a Division I would like to filter the dept. But it seems that the value I get when I try to filter when the div changes is the array index not the value of the division. Basically what I've done is set the valueChangeListener to a function on the backing bean for the Div selectOneChoice and set auto submit to true. If I look at the values on the valueChangeEvent they are the indexes not the actual values. I've tried using ExecuteWithParms in the page def and binding to to #{bindings.div.inputValue} but the results are the same the inputValue at this point contains the array pointer not the actual value. as seem by turning on -Djbo.debugoutput=console.
    Does anybody have any suggestions?
    Thanks
    Chris

    Scott - check out Re: How to do? Save-and-Return with ADF Faces and ADF BC, JDev 10.1.3
    John

  • How to invoke bean method after query executed?

    Jdeveloper 11.1.1.2:
    I have a bean that backs a JSF page.
    The bean has a method that shows/hides certain GUI components based on the values of other components.
    I would like to invoke this method automatically after the page has been fully loaded.
    I tried invoking the method in the AfterPhase of the f:view and at bean construction time. Both approaches failed.
    I think I need a listener that gets invoked after the query has been executed.
    Any idea?
    thanks

    Hi,
    if the bean is a backing bean and it is supposed to hide components, then why don't you create a reference of the components to the backing bean so that the displayed property is dynamically evaluated ? Sounds like this is what you want to do
    Frank

  • ADF Faces - Select data from a table row

    Hi! I have to build a Select One table but I'd like to use instead the combination: radio button (to select) command button (to submint), only a command button placed in each row wich make both action with a single click.
    Is it possible? How?
    Thanks!

    Maybe some variant of the below will work for you:
    SELECT *
    FROM  
            SELECT transaction_id
                 , employee_name
                 , customer_number
                 , customer_name
                 , ROW_NUMBER() OVER (PARTITION BY employee_name ORDER BY DBMS_RANDOM.RANDOM) AS rn
            FROM   tbl_transactions
    WHERE rn <= 10
    ;

  • ADF Faces: How to position define table navigation in custom skin?

    Hi,
    I played a bit with custom skins. I'am just wondering how you can choose the location of the navigation button ( << Previous | 1-10 of 32 | Next >> )
    For example, if I use the oracle skin, it appears both at the top and at the bottom. In an other skin I used, the navigation was only at the top and not at the bottom. I just can't figure out how this is determined in the css stylesheet, or is it simply not possible because the custom skin is derived from the Simple skin?

    Add the following to the css for your skin:
    af|table::control-bar-bottom
    visibility:hidden;
    This will hide the bottom control bar, which contains the navigation at the bottom of the table, from view.
    Regards,
    Ric

Maybe you are looking for