Use Faces Managed Bean in javaScript

Thanks in Advance
Scenario:
I have got a faces manged bean that constucts a string array .On my page i have got select one list box .Based on my selection ,message to be displayed at the bottom of the page or a pop up window .This string array corresponds to the list box items description.
I am doing an onclick() event ,when i click on an item in the list ,display the pop up window with the message. here i need to call the FACES MANAGED BEAN
to display the message in the pop up window.
Can any one suggest a way for this to start.
than u

Use a ValueChangeEvent to do that.

Similar Messages

  • 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

  • Customize faces managed bean loading in ADF ( in JDev 11.1.2.1)

    Hi there,
    I am trying to use Spring with ADF. The intention is to use Spring context managed beans to use as backing beans in ADF.
    I created a simple bean class. Created Data control based on it and tried to look at factoryClass, which is responsible for instantiating the bean class, oracle.adf.model.adapter.DataControlFactoryImpl.
    Where in ADF it creates the instances of backing beans? What is the best approach to solve this puzzle?
    With regards,
    - Manoj
    ----------

    Manoj
    I don't think your version of Jdeveloper supports CDI beans. It is my understanding that CDI beans will be supported next year in Jdeveloper.
    So for now, if you are using Jdeveloper, you are stuck with only JSF managed beans that need to go in the faces-config.xml files or managed beans annotations .....
    Yesh

  • How to pass js variable to be used in managed bean constractor?

    Hi,
    I got a list of items that i present in <h:selectOneMenu on my page (the first page the user sees)
    the labels that are shown in the ><h:selectOneMenu are date + time , and the time itself is stored in the db in UTC without any + or - timezone offset (e.g UTC +2)
    In order to show the correct time in the labels of the ><h:selectOneMenu I'm adding the needed offset of the user timezone
    the problem is that the ><h:selectOneMenu is being populated from the managed bean before I'm passing the offset from the xhtml page itself using jQuery $.post(
    like this
    <h:head>
    <script type="text/javascript">
              jQuery(document).ready(function($) {
                   d = new Date();
                   var tz = -1 * d.getTimezoneOffset()/60;
                   $.post("/servlets/TimeZoneFromClientServlet",{timezone : tz});
           </script>
         </h:head>any ideas how can i pass the TimezoneOffset to the application before the managed bean is loaded?
    Thanks ahead!
    Daniel.

    You know, any website I've encountered so far ASKS for your timezone. Why do you think that is?
    In any case, if you really want to go ahead and do what you want, you need a single point of entry in your web application that sets the timezone in the session once so you can reuse it. It could be something as simple as doing it in a login page if you have one; just create a hidden input field that is prefilled with the timezone you find using Javascript; then simply submit it to the server and stick it in the session there. When the session times out the user would have to login again, which would give you the timezone value back.
    another option: is the managed bean session scoped? If so you can simply fetch it in your servlet and update the appropriate property of the managed bean. This one makes me feel some shame for suggesting it though.

  • How do I use a managed bean in another managed bean

    I have two managed beans. One is backing bean for a form and the other is used to access a database table.
    1st bean
    public class TestDBAO
    @PersistenceContext
    private EntityManager em;
    public void addEntry(PersonObj person)
    em.persist(person);
    public class formdata
    private String id;
    private String fname;
    private String lname;
    getter functions
    setter functions
    public String submit()
    in here i want to call addEntry function from TestDBAO
    How can I achieve this or is there another way to do this?

    Do I understand correctly that you have definied TestDBAO as a session scoped managed bean? Why?
    You don't need that. Just create and call TestDBAO in the backing bean. Or if you want only one instance of TestDBAO during the session, then create a singleton constructor and eventually make the methods static.

  • How to use a managed bean in a bounded task flow without definig it in adfc-config

    Dear all
    I create a bounded task flow without page fragments (the pages are jspx), i created a jspx page with a button that its action has bounded to a managed bean function.
    i defined the managed bean on the corresponding bounded task flow, but it does not work.
    But there is no problem when i define the managed bean in adfc-config.xml.
    can anybody help me with this problem.
    is it possible to use jspx page with backing bean in bounded task flows, without defining the beans on adfc-config?
    Thank you very much

    Dear Timo
    I use jDev 11.1.1.6 and the scope is Request.Although when i use task flow page fragment and create jsff pages, there is no problem.

  • Use ADF Managed Bean to get the username in BPM Workspace

    Hi all,
    I used JSF and ADF to build the UI of human task. And I want to get the username of the user who is manipulate on BPM Workspace. For example, an ADF form can display the username of current user in BPM Workspace. I also try this approach: use Manage Bean, and bind this bean to a output text in ADF form. The code fragment I use to get the current username is:
    ADFContext.getCurrent().getSecurityContext().getUserPrincipal().getName();
    But it does not work. The value I get is Anonymous.
    So, plz help me solve this problem

    Hi, please try this function as below:
    public String getUserLogin() throws WorkflowException,
    BPMIdentityException,
    BPMUnsupportedAttributeException {
    String userId = "";
    IWorkflowServiceClient wfSvcClient;
    ITaskQueryService queryService;
    IWorkflowContext wfContext;
    // Get username of User Login
    String contextStr = ADFWorklistBeanUtil.getWorklistContextId();
    wfSvcClient = WorkflowService.getWorkflowServiceClient();
    queryService = wfSvcClient.getTaskQueryService();
    wfContext = queryService.getWorkflowContext(contextStr);
    userId = wfContext.getUser();
    return userId;
    Regards.

  • Which view object classes should be used by managed bean in ViewController?

    I just like to find out which java implementation classes created for a view object should be referenced in a managed bean on the UI side.
    For my view object InfoVO, I can create the following classes:
    View Object class: InfoVOImpl
    View Row class: InfoVORowImpl
    View Row Client Interface: InfoVORow
    View Row Client Class: InfoVORowClient
    Currently, I use InfoVOImpl and InfoVORowImpl in my managed bean so that I can use the getter methods conveniently to access the attributes with proper data types.
    I am not sure when I should use InfoVORow and InfoVORowClient instead of InfoVORowImpl.
    What are the context and reasons for using InfoVORow or InfoVORowClient instead of InfoVORowImpl?

    Hi,
    all of these are wrong. If you want to access a method exposed on a ViewObjectImpl class, the you expose the method as a clientMethod (or clientInterface) in the Java options for the View Object (or Application Module if the method is on AMImpl). You should avoid using implementation classes directly in the managed bean. If you need to access a View Object, use its interface ViewObject. If you need anything more specific than that, expose a method on the client interface after which you can access it through the binding layer.
    Frank

  • How to set the value of process variables/payload using a managed bean?

    Hello,
    Someone can give me an example about how to set the values of a process payload in a managed bean?
    thank you!

    Try this:
    jsf page:
    <af:selectOneChoice label="Select Suburb"
    requiredMessageDetail="Select a suburb"
    valueChangeListener="#{selectOneChoiceBean.onValueChanged}"
    validator="#{selectOneChoiceBean.validate}"
    unselectedLabel="None" autoSubmit="true"
    binding="#{selectOneChoiceBean.selectOneChoice}"
    value="#{selectOneChoiceBean.value}">
    <f:selectItems value="#{selectOneChoiceBean.selectionList}"/>
    </af:selectOneChoice>
    backing bean:
    public class SelectChoiceBean {
    private List<SelectItem> selectionList;
    private String value = "B";
    private RichSelectOneChoice selectOneChoice;
    public SelectChoiceBean() {
    initSelectionList();
    public void setSelectionList(List<SelectItem> selectionList) {
    this.selectionList = selectionList;
    public List<SelectItem> getSelectionList() {
    return selectionList;
    public void onValueChanged(ValueChangeEvent valueChangeEvent) {
    System.out.println(valueChangeEvent.getNewValue());
    // Add event code here...
    public void validate(FacesContext facesContext, UIComponent uIComponent,
    Object object) {
    // Add event code here...
    private void initSelectionList() {
    selectionList = new ArrayList<SelectItem>();
    selectionList.add(new SelectItem("A", "A label"));
    selectionList.add(new SelectItem("B", "B label"));
    selectionList.add(new SelectItem("C", "C label"));
    public void setValue(String value) {
    this.value = value;
    public String getValue() {
    return value;
    public void setSelectOneChoice(RichSelectOneChoice selectOneChoice) {
    this.selectOneChoice = selectOneChoice;
    public RichSelectOneChoice getSelectOneChoice() {
    return selectOneChoice;
    }

  • How to use remote managed bean and JPA in JSF

    Hi All,
    I am familiar with referencing backing-beans and JPA properties where Glassfish and MySQL is running locally. However, is it possible to lookup these same properties using JNDI if they reside on remote servers? If so, what change is needed?
    I would like to distribute the J2EE 5 application load including database by running Glassfish, MySQL on separate servers. This will put on the JSF (presentation-tier) components on it's own server while a secondary system will handle the middle tier processing and leaving the database activities to be carried out on another server. Not sure whether this is the right approach though. These hardware would run on both Solaris and Windows platforms.
    Unfortunately, buying faster hardware is not an option.
    Any assistance would be appreciated,
    Jack

    Hi Faissal,
    Is your suggestion below:
    //Lookup an EJB and use it
       YourRemoteBean bean = (YourRemoteBean ) ServiceLocator.findRemoteObject(jndiName); // ServiceLocator is a class that lookup
                                                                                                                                           //  the remote objectis equivalent to the following lines:
    Properties props = new Properties();
        props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
                props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
                props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
                // optional.  Defaults to localhost.  Only needed if web server is running
                // on a different host than the appserver   
                // props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
                props.setProperty("org.omg.CORBA.ORBInitialHost", "remoteServer");
                // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
                // props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
                InitialContext jndiContext = new InitialContext(props);     
                InitialContext jndiContext = new InitialContext();
                YourRemoteBean bean =  (YourRemoteBean) jndiContext.lookup("ejb.YourRemoteBean");Thanks,
    Jack

  • About Using the managed-bean Element

    Initializing Managed Bean Properties
    why referenced bean can't instantiate? Please help.
    <managed-bean>
    <managed-bean-name>customers</managed-bean-name>
    <managed-bean-class>test.Customers</managed-bean-class>
    <managed-bean-scope> session</managed-bean-scope>
    <managed-property>
    <property-name>mailingAddress</property-name>
    <value>addressBean</value>
    </managed-property>
    </managed-bean>
    managed-bean>
    <managed-bean-name>addressBean</managed-bean-name>
    <managed-bean-class>test..AddressBean</managed-bean-class>
    <managed-bean-scope> none </managed-bean-scope>
    </managed-bean>

    Hi,
    Maybe this helps:
    When you create an object that points to other objects, do not try to point to an object with a shorter life span.
    A scope of "none" means that the bean is created only when something else references it.
    The life span is in this order: none, application, session, request .
    Best regards,
    Nick

  • ADF Faces: Managed Beans

    Hi All,
    I have a situation where i need to pass the value to managed bean at runtime which inturn changes the values of menubar,menulist please can any one help me out.
    Regards
    Manasa Chanda

    What you probably want to do is expose the menubar.menulist component to your managed bean. This is fairly easy to do by editing the "Binding" property of the component. This will let you specify a Managed Bean, and a Property, or you can press a New button to create the bean, and/or the Property. Once you've exposed the component, the properties of the component are available through EL, including being able to change those properties from other components.

  • ? on using faces-config bean properties

    I like the idea of being able to set bean property values in faces-config - one because it's sort of self-documenting and two because I can change my app without re-compiling. Now from what I've read and from tests I've conducted, the bean is instantiated on first reference from a jsp - the framework calls the no-arg constructor and then calls the setter methods for any faces-config properties. Fine. But what if these properties are central to the bean's behavior - say they're used in the calculation of other properties. I don't have access to them in the constructor, and trying to do something in the setter for each property would be messy. Any ideas, or am I missing something fundamental?

    You have the correct understanding. What I would do if I had a property that was dependant on the value of other properties is do the calculation in the getter of that property. As you said, trying to do it in the setter of the other properties would be messy to say the least. Also, be aware that JSF 1.0 has a bug in that it does not support setting nested properties from a faces-config file.

  • How do you use one managed session bean from another?

    Hello -
    I am a complete newbie to JSF coming from Struts 1. My question is how do you use one managed bean from the method of another one? I think this would be a common senario. For example I put a bean in session scope when a user logs in and in a different method within a different bean I want to get some of this user's information. What is the correct way to retireve one bean from a method in another with session scope?
    Also what would the code look like to retieve another bean from the method of a managed bean where the bean you want to retrieve has application scope?
    Thank you in advance.

    Sinplicity wrote:
    Could you be a bit more specific? If a bean is configured in the faces config file then all of it's properties are managed, correct?Not necessarily.
    What would the code look like to retireve the bean?You don't retrieve it, it has been injected.
    Can I retrieve the whole bean or just a property of the bean. I would be really interested in seeing how this is done in code? And would really love a bit more information on what it means to be a managed property?Time to consult a JSF tutorial.

  • Keeping session using custom save button in managed bean

    Greetings,
    I'm building a application based on BC + ADF(JSF).
    All around the app. I need two buttons, one for committing and actualizing the UI data, and other to return to the previous page.
    Instead of customizing those buttons every time they occurs, I've haded a managed bean to do the work. This managed bean as "request" scope.
    The process of editing a form, requires me to have one form to only view the data and other to edit the data.
    The issue is: when saving a form, it should return ("back" action) to his precedence, keeping the session state.
    That is: If I'm editing "process 2" when i commit it should go to "process 2" in read only mode.
    This works fine if i use "hardcoded buttons", but when i use the managed bean to handle those buttons action, when committing, it goes to the first on the list. It doesen't keep the session state.
    How can i keep the state ?
    Thanks
    here it is the managed bean:
    package fc.view.backing;
    import fc.model.FirstCareAppModuleImpl;
    import javax.faces.context.FacesContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.view.faces.component.core.nav.CoreCommandButton;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import oracle.jbo.ViewObject;
    public class fcLib {
    private BindingContainer bindings;
    private CoreCommandButton commandButton_save;
    private CoreCommandButton commandButton_backOnePage;
    private CoreCommandButton commandButton_backHome;
    * Get and set bindings
    public BindingContainer getBindings() {
    return this.bindings;
    public void setBindings(BindingContainer bindings) {
    this.bindings = bindings;
    * Getters ans setters for "save" and "back" buttons
    public void setCommandButton_save(CoreCommandButton commandButton_save) {
    this.commandButton_save = commandButton_save;
    public CoreCommandButton getCommandButton_save() {
    return commandButton_save;
    public void setCommandButton_backOnePage(CoreCommandButton btn) {
    this.commandButton_backOnePage = btn;
    public CoreCommandButton getCommandButton_backOnePage() {
    return commandButton_backOnePage;
    public void setCommandButton_backHome(CoreCommandButton btn) {
    this.commandButton_backHome = btn;
    public CoreCommandButton getCommandButton_backHome() {
    return commandButton_backHome;
    * Back actions for back buttons
    public String commandButton_backOnePage_action() {
    return "back";
    public String commandButton_backHome_action() {
    return "home";
    * Save button action - Used in al pages that do save (commit) data
    public String commandButton_save_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("Commit");
    OperationBinding operationBinding2 = bindings.getOperationBinding("Execute");
    operationBinding.execute();
    operationBinding2.execute();
    // It should be a error page
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    // Refresh main view object
    DCBindingContainer bc = (DCBindingContainer)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("bindings");
    FirstCareAppModuleImpl fc = (FirstCareAppModuleImpl)bc.findDataControl("FirstCareAppModuleDataControl").getDataProvider();
    ViewObject vo_SitSocProf = fc.findViewObject("EpisodiosMain");
    vo_SitSocProf.executeQuery();
    System.out.println(" All done. Ciao ");
    return "back";
    }

    Hi
    I re-execute the query only to refresh the AM VO data.
    I'm using AM EO to access DB Views, that use IOF triggers to update/insert/delete into the DB.
    Using the application, when updating data, changes wont reflect in the UI if I don't refresh the "master" VO, that is "EpisodiosMain". I'm doing a commit and a execute to a "detail" VO.
    "If you need to execute the query and set it back to the last row you worked with, get the row key before executing the query so you can set the current row back to this rowkey"
    Could you please throw a example on how to do this ?
    "Reaching through to the AM to execute the VO isn't best practices. You should grap the associated iterator in teh binding instead and perform the execute operation. Note that usig ADF binding there are only rare situations in which you need to access teh business service directly as you do. "
    Again, could you please post an example of how to do this, or introduce me to some documentation.
    Thanks
    Message was edited by:
    Buondi

Maybe you are looking for