How to call a bean method in the faces-config file?

Hi,
I would like in my menu to call the method of a bean (it initialize some properties before opening the page) instead of opening directly the page, by I can't find how to do that.
I tried :
<managed-property>
<property-name>viewId</property-name>
<value>#{listInformationsController.listInformations}</value>
</managed-property>
And :
<managed-property>
<property-name>outcome</property-name>
<value>#{listInformationsController.listInformations}</value>
</managed-property>
With no success...
Can someone help me?
Thank you and merry christmas !

Hi,
a managed property only gives you a anlde to a bean or property, it doesn't execute it. To execute a bean, you can use a custom JSF PhaseListener that calls a bean method. The reference to the bean is achieve through value binding
ValueBinding vb = FacesContect.getCurrentInstance().getApplication().createValueBinding("Name of Managed Bean);
TypeOfBean theBean =(TypeOfBean) vb.getValue(FacesContext.getCurrentInstance());
.... theBean.theMethod() ...
Frank

Similar Messages

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • 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

  • How to call a bean method through a javascript function

    I dont discover any problems calling the bean method in this maner:
    <%= helpdesk.data() %>
    But, when I use a Button Onclick= to call the script function and which then is going call my bean method
    an error on the page is reported!
    I have include som code which gives you the idea of what Iam searching for. And is it possible to call
    the bean method without doing from a new jsp page?
    If you have any suggestions to why it doesnt work, please let me know.
    I use Apache Tomcat 4.0
    Best regards Micah.
    <jsp:useBean id='helpdesk' scope='application'
    class='helpdesk.testdb'/>
    <html>
    <head>
    <script language="javascript">
    function broadcast()
    helpdesk.data();
    </script>
    </head>
    <body>
    <input type="button" value="Broadcast" onclick= broadcast()>
    </body>
    </html>

    It's actually quite simple:
    Beans run server-side
    Javascript runs client-side
    So you will never be able to run server-side-code thru the client...

  • How to call  a javascript method after the PPR event has finished  ?

    Hi!
    How can we make a javascript method get called after the processing of ADF PPR event?
    My specific use case is,
    I want to call a javascript function after the data in the table is loaded...
    In 10g, that is not a problem, as the data used to get loaded directly during onLoad, and so i would call my js function on load;
    but in 11g , the table data is being loaded through PPR which is initiated onload, and so i needed to call my function after the PPR Response processing has been done; for which I need the name of the event triggered at that instance.
    Is it possible to do this?
    Regards,
    Samba

    Hey, I got it.
    I handled the ADF Controller's PREPARE_RENDER_ID phase of the lifecycle, and then called the
    script to get Executed.
    The code :
        public void afterPhase(PagePhaseEvent pagePhaseEvent) {
            FacesPageLifecycleContext ctx = (FacesPageLifecycleContext)pagePhaseEvent.getLifecycleContext();
                 if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_RENDER_ID) {
                    if(AdfFacesContext.getCurrentInstance().isPostback() )
                        afterRender();
        }is written in lifecycle listener , and my backing bean extended this listener ,
    and in the afterRender() method I did this :
       public void  afterRender(){
                System.out.println("AFTER RENDER CALLED");
               FacesContext context = FacesContext.getCurrentInstance();
               ExtendedRenderKitService service = (ExtendedRenderKitService)Service.getRenderKitService(context, ExtendedRenderKitService.class);
               service.addScript(context, "translate();");
           }That's it.
    It did work, magnificently.
    Thanks for the idea.
    Regards,
    Samba

  • How to call Backing Bean method from href tag in JSF. -- URGENT

    Hi guys,
    i am new to JSF. i want one option. how to call a backing bean method from href.
    I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
    If anyone knows pls help me. Its Urgent. If u can, give me the code also.
    Suggestions will be appreciated.
    Thanks
    Rajesh

    You can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
    You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html].

  • How to call standard SAP method in the Custom Program ?

    Hi,
    i need to call sap standard method 'OpenItemRollinout' in my custom program. For the SAP Standard method 'OpenItemRollinoun' the BOR(Business Object) is 'PAYSCHEME'. So how to call the SAP standard method in the custom program ???

    Hi,
    In the method that you have provided only one function module is being used so better use the FM and copy the remaining code based on ur requirement.
    FM is ISU_S_PAYSCHEME_ROLLIN_ROLLOUT.
    Regards,
    Vijay.

  • How to call backing bean method when user tabs out of af:inputListOfValues field

    Hi,
    I am using jdev 11.1.2.4.
    I want to call a backing bean method based on the value selected in the af:inputListOfValues field.
    The requirement is similar as Frank Nimphius-Oracle has demonstrated here  https://blogs.oracle.com/jdevotnharvest/entry/how_to_notify_the_server but with Input List of Values component.
    The fields I want to call method from is
    <af:inputListOfValues id="appealNameId"
                          popupTitle="Search and Select: #{bindings.AppealName.hints.label}"
                          value="#{bindings.AppealName.inputValue}"
                          label="#{bindings.AppealName.hints.label}"
                          model="#{bindings.AppealName.listOfValuesModel}"
                          required="#{bindings.AppealName.hints.mandatory}"
                          columns="#{bindings.AppealName.hints.displayWidth}"
                          shortDesc="#{bindings.AppealName.hints.tooltip}"
                          binding="#{backingBeanScope.backing_Donation.appealNameId}"
                          autoSubmit="true" clientComponent="false">
                          <f:validator binding="#{bindings.AppealName.validator}"/>
                          <af:autoSuggestBehavior suggestedItems="#{backingBeanScope.backing_Donation.onSuggestAppeal}"/>
                          <af:clientListener method="onBlurTxtField" type="blur"/>
    </af:inputListOfValues>
    <af:serverListener type="onBlurNotifyServer"
                       method="#{backingBeanScope.backing_Donation.onBlurNotify}"/>
    as you can see,  af:serverListener is outside the af:inputListOfValues which probably is the reason its not executing this method?
    public void onBlurNotify(ClientEvent clientEvent) {
       // get a hold of the input text component
       RichSelectOneChoice inputTxt =  (RichSelectOneChoice) clientEvent.getComponent();
       //do some work on it here (e.g. manipulating its readOnly state)
       //Get access to the payload
       Map  parameters = clientEvent.getParameters();
       System.out.println("SubmittedValue = "+parameters.get("submittedValue"));
       System.out.println("LocalValue =  "+parameters.get("localValue"));
    I've tried to put serverListener tag inside the <af:inputListOfValues> but getting below error
    "Server Listener is not valid child of Input List of Values"
    any ideas please?
    thanks

    As first, check to see that you are using correct type for af:serverListener (thet one you are queue in the javaScript onBlurTxtField function)
    If still does not work, go to directly to the page source code, and put af:serverListener "by hand", as a child for af:inputListOfValues.
    Because it is possible that these messages are false alarm...

  • How to call a bean method from html component in jsf

    hi all
    i need a solution for this problem of mine.. actually em working on a jsf application with contains a jsf-jsp having a span containg html button inside my javascript. i want to call a method on click of this button and fetch some data which i have already populated in my bean.how do i do this??? i hv attached a piece of code of d same...
    <script language="JavaScript" type="text/javascript">
    function test(form){
    var Title="DEBIT, gift, Request, TICK";
    var Span=document.createElement("Span");
    Span.style.position="absolute";
    Span.style.left=(parseInt(110)-5)+"px";
    Span.style.top=(+parseInt(274)-5)+"px";
    Span.style.backgroundColor='Red';
    var next=document.getElementById("forImage");
    next.innerHTML="<img src='http://127.0.0.1:9000/action=clusterserve2dmap&sourcejobname=myjob_clusters' />";
    Span.innerHTML="<[input type='button' >";
    document.getElementById("forImage").appendChild(Span);
    any help is highly appreciated

    Hi,
    this gonna be a hack, but here's how it could work
    - you create a Servlet that accesses the FacesContext to obtain a managed bean
    - you issue a XmlHttpRequest from the button to your servlet to obtain the payload
    - show the retrieved values in your HTML
    see http://www.thoughtsabout.net/blog/archives/000033.html for the middle part
    Frank

  • How to call Backing bean method from JS

    I want to call commandlink action from JS,
    I'm trying document.getElementById('formPageInfo:btnCreateQuote').click() in javascript.
    But it is not working any ideas around?
    Code is for commandlink : <h:commandLink action="#{ManagedController.businessListActions.createNewQuote}" accesskey="C" title="Start Quote" id="btnCreateQuote"> <h:outputText value="Start Quote" /></h:commandLink>
    Any help/Suggestions around?

    I think that not exist a specific way to do it with jsf. Maybe you should ask in other forum more related with javascript, as a tip, if you can use jQuery in your environment, jQuery.trigger() can simulate a click on a button or command link. I have used it with a h:commnadLink and worked fine.

  • How to call a previous operation in the routing in the backend?

    (We have a requirement to call a previous operation in the routing in the backend and create-assemble-complete the SFC.)
    Routing would be u2013 OPERATION_1 -> OPERATION_2 -> OPERATION_3
    The SFC has not been create and we are using u201CCreate SFC On Demandu201D.
    The production operator is given the SFC value to use, however, the POD is configured to START the SFC at OPERATION_2
    The desire is to process the SFC at OPERATION_1 as a u201Cblindu201D operation to production.
    The question: If we use a PRE_START activity, is it possible to launch the PRE_START activity at OPERATION_2 and have the activity:
    1) Create the SFC,
    2) Start the SFC at OPERATION_1,
    3) Assemble a child SFC (part of the activity information),
    4) Complete the SFC at OPERATION_1,
    5) Upon completion of the SFC at OPERATION_1 finalize the activity and allow the SFC to start at OPERATION_2 normally?
    Thanks and Regards,
    Avinash
    Edited by: Avinash Fernandes on Feb 16, 2012 3:30 AM

    Hi,
    a managed property only gives you a anlde to a bean or property, it doesn't execute it. To execute a bean, you can use a custom JSF PhaseListener that calls a bean method. The reference to the bean is achieve through value binding
    ValueBinding vb = FacesContect.getCurrentInstance().getApplication().createValueBinding("Name of Managed Bean);
    TypeOfBean theBean =(TypeOfBean) vb.getValue(FacesContext.getCurrentInstance());
    .... theBean.theMethod() ...
    Frank

  • When do you need to register the message bundle in the faces-config

    hello
    i have applied two examples to localize messages, label, title by creating message.properties file and utilizing the f:loadbundle component the EL expression. It works like a charm without having to register anything, I have only registered the locale, but not the bundle
    also , i have used a programmatic approach
    FacesContext fc = FacesContext.getCurrentInstance();
    ResourceBundle msg = ResourceBundle.getBundle("message",fc.getViewRoot().getLocale());
    fc.addMessage(FacesMessage.SEVERITY_FATAL.toString(),new FacesMessage(msg.getString("ok")));
    which also worked without registering the message bundle!!
    although many article i read ask to register the message bundle.
    Another thing is that in Oracle Jdeveloper 10g for FORMS and PL/SQL Developers states that the message file needs to be located in \resource subdirectory
    and using getBundle (resources.message) to get it. In fact i kept getting errors indicating that the base bundle cannot be read until i located the file in the ViewContoller directory itself (and that is why i reference it with getBundle("message") rather than resources.message as indicated in the book.
    appreciate your response
    ammar sajdi
    amman - jordan

    Hi,
    Your question is not very clear. But let get through some various guideline.
    <f:loadBundle/> is horribly buggy and was all but removed from the specification. As a tag, it gets only evaluated during the render view phase, meaning that if you have EL expression referring the loadBundle's var during another phase, it's going to fail. The most common case is during validation with overridden messages.
    About the programmatic access, the problem is that you're linking your application to a specific bundle at code level. Meaning that you're preventing it to be reused in a different context, while the following get the most application local bundle name (faces-config.xml's message-bundle property)
    Resourcebundle.getBundle(FacesContext.getApplication().getMessageBundle())Registration is also the only way to override the default conversion / validation messages.
    For JSF 1.1 (10g), those are your option. However, if you're using JSF 1.2 (11g), you can also register resource bundles in the faces-config file, you then register the bundle and the var associated to it, removing the need of f:loadBundle and fixing the non render phase issues. furthermore, the code version is also simplified to:
    FacesContext context = FacesContext.getCurrentInstance();
    ResourceBundle bundle = context.getApplication().getResourceBundle(context, "varName");
    bundle.getString("myKey");You other part about \resource I never heard of nor cared for. You can place the bundle where you like on the classpath.
    Regards,
    ~ Simon

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • How to achieve Entity Bean methods ONLY by calling them from a Session Bean

    Hi,
    I used a session bean as a business facade to a entity bean.
    In the session bean I achieve the entity bean with a jndiContext.lookup("java:comp/env/ejbEntityBean").
    Now I am looking for a solution that it is only possible to call the entity bean methods or the whole entity bean from the corresponding session bean.
    In other words: "How can I forbid the access to the entity bean, if the calling object is not the corresponding session bean?"
    --->
    I only found a way the regulate the access to the entity bean methods by declaring a security-role.
    But the existence of the security-role at runtime depends on the calling user-authorizations!
    Is there a way to set the entity-security-role within the session bean context?
    Best Regards
    Steffen

    Hi Srikanth Reddy.T,
    sorry, I am not looking for a special tag  <entity-security-role>.
    I am looking for a way to specifiy that my session bean "has" the special security-role (in my case "WebZaehlerEjbRole") of my entity bean "in my case "WebZaehlerEjbRole") that is necessary to call the methods (findAlleEntries, findByWindowId,...) of my entity-bean.
    Here is the relevant part of my ejb-jar.ml:
         <assembly-descriptor>
              <security-role>
                   <role-name>WebZaehlerEjbRole</role-name>
              </security-role>
              <method-permission>
                   <description>method-permission</description>
                   <role-name>WebZaehlerEjbRole</role-name>
                   <method>
                        <ejb-name>WebZaehlerBean</ejb-name>
                        <method-name>findAllEntries</method-name>
                        <method-params/>
                   </method>
                   <method>
                        <ejb-name>WebZaehlerBean</ejb-name>
                        <method-name>findByWindowId</method-name>
                        <method-params>
                             <method-param>java.lang.Long</method-param>
                        </method-params>
                   </method>
    Regards,
    Steffen

Maybe you are looking for

  • How can I get Photoshop CC to stop crashing? (Windows 8.1, GeForce GT 755M)

    OS Windows 8.1 64bit Processor Intel Core i7-4700MQ @2.4Ghz, 4 core RAM 16G Available Memory 13G Graphics card GeForce GT 755M (up to date driver) Bits/Pixel: 32 4096MB available graphics memory As you can see I have plenty of Ram on this computer, y

  • How to use Labview6i with the LPT1 port ?

    I am a beginer in Labview 6i on Windows NT. My DAQ card, which is not from National Instruments, is connected to the LPT1 port and I don't know how to configure and tu use it. Maybe someone could help me.

  • Can I export photo's from my MacBook Pro to My Ipad 2

    Can I export photo's from my MacBook Pro to My Ipad 2.

  • Removing Extra Stuff from Scanned Page...

    Hi All, I have a scanned page saved as a JPEG file. The page contains handwritten stuff (like text or drawings in black or colored ink). How to remove extra stuff like page shrink marks or background of the paper from the scanned page so that only wr

  • IWeb and HTML Help

    Hey, Im using iWebMore to use html. I tried it to make an iFrame, didnt work, tried to embed a YouTube video, didnt work. So I tried something simple such as: <@: Hello!<hr/>Bye :@> which will simply but Hello! over Bye with a line between them. Howe