Binding a Bean to Component

hello!
i would like to bind a bean to a component from a jsp...
the jsp:
<jsp:useBean id="myBean" class="src.veranst.VeranstaltungBean" scope="session"/>
<jsp:setProperty name="myBean" value="2.4.2000" property="startDate" />
<f:view>
  <h:form>
    <pkg:DateInput date="#{myBean.startDate}" />
    ...I don't understand why my "DateInput"-component is called with the string "#{useBean.startDate}" and not with the value of the bean-property. I've also tried to define the component with the <managed-bean>-tag in the faces-config.xml.
thanks,
Hanspeter Klapf

When I log the param date from the method setDate(), it has the value "#{myBean.startDate}".
Shouldn't the string contain the value of myBean.startDate and not its name? The value here is only the string "#{myBean.startDate}", it will be convert to the value of the myBean.getStartDate() in future(in the setProperties function...)
The method setProperties then would cast the UIComponent to the type of my own component and >assign the value date to the corresponding property of the component, or am I wrong?Please write the setProperties() method like this:
        if (( date != null) {
            if (UIComponentTag.isValueReference(date )) {
               //since the jsp code will use    date="#{myBean.startDate}", this condintin will be true and executed
                javax.faces.el.ValueBinding vb = getFacesContext().
                                                getApplication().
                                                createValueBinding(date );
               //here will get the value that stored in your bean named "myBean"
                command.setValueBinding("date ", vb);
            } else {
                command.getAttributes().put("date ", date );
        }and your UIComponent should be written like this:
  public Object getDate(){
        if (date!= null) {
            return date;
       //if your jsp use date="#{myBean.startDate}", the date  variable will be null, and execute the statements belwo.
        ValueBinding vb = getValueBinding("date");
        //this statement will get the value from your bean named "myBean" and use the getter method
        if (vb != null) {
            return vb.getValue(getFacesContext());
        } else {
            return null;
    }hope be helpful.
David

Similar Messages

  • How to bind the bean and textfield which is written in html tages?

    Hi,
    I am doing the add row functinality using javascript. i am able to add the rows .but how can i bind the bean variables to the html code written in jsf applivation
    for example
    newQuotCell1[0].innerHTML='<input type=text class=TextField name="name'+count1+'" value="<f:verbatim><h:outputText value="#{employeeInfo.name}"/></f:verbatim>">';
    can i binc the bean variable with the input textbox like the above
    if its wrong can u suugest me some thing or guide me . so that i can move on
    thansk in advance dude

    This code piece is just plain stupid. JSF runs at the server side and JS runs at the client side.
    If my guess of your requirement is right, checkout the h:dataTable component.

  • How add auto binding backing bean to a jspx page

    A few times during development, I didn't check "automatically expose UI components to in a manage bean" when the jspx page was first created.
    Can someone tell if there is a way to add auto binding backing bean to the page later?
    Thanks

    Hi Deborah,
    when your JSPX page is active, select menu Design -> Page Properties...
    Click Tab Component Binding
    Select Auto Bind and select (or create with New) your Managed Bean
    Regards,
    Didier.

  • Property binding causes Bean property to be null when Component is readonly

    I am retrieving an object (instantiation of a Bean) from a list of objects displayed in a table.
    A set of components (textfields, textareas) are bound to the properties of the retrieved object. - propertybinding, text property bound to name property of managed bean.
    If I make any of the bound components read-only the corresponding property of the bound object is set to null.
    Why is this? Is there a work-around for this? If there is not I will not be able to make use of the propertybinding feature and I will have to populate and retrieve from components manually.
    I have tested this using different components and setting up binding in multiple ways - through "data binding" and through "property binding" directly to the text field of the component.
    Thanks,

    I have been working with my issue for a little bit and I've learned that binding to an object (or Bean) can be dangerous for the object.
    In SessionBean1 I have instantiated two objects of my bean TransferMethod, tm1 and tm2. tm2 is a "copy" of tm1 in that it contains all the same data, but in separate memory.
    I've bound tm1 to text fields on my jsp page. tm2 is not bound to anything.
    My page has a table, and edit area and several buttons. When I load my page it populates the table with data. I select a row from the table and click my "Edit" button. This instantiates the tm1 and tm2 objects and populates them with data from the row.
    As my text fields are bound to tm1 the text fields are now populated when the page is re-displayed. The name field is bound to the name property and the component is set to readonly. The description field is bound to the description property and has no other configuration.
    When I click my "Save" button and interrogate my tm1 and tm2 objectsm all properties in my tm1 object are reset to default values with the exception of the description field. All properties of the tm2 object are still populated with original data.
    This tells me that binding an object to components is not feasible if you expect to continually work with that object on a single page.
    My work around will be to manually assign the properties of my object to my textfields and vice-versa.
    Hopefully the new version of Creator will address this issue.
    Rebecca

  • Component attribute binding with bean property

    I have a component which i use in JSP something like this:
    <A: myComponent
    attributeVal=#{myBean.value}
    />
    in myBean:
    I have [b]getValue() and setValue().
    If i call setAttribute() function of myComponent programatically,
    say
    MyComponent myComp = (MyComponent ) uiComponent; // line 1
    myComp.setAttribute(10); // line 2
    Will statement at line2 cause myBean property to be updated?
    Thanks for your help...

    So..What can I do to the achieve the same
    functionality. Something like:myComp.getValueBinding("attributeVal").setValue(facesContext, value)

  • Binding  to Faces Client Component (Tree view)

    Hi experts,
    I am trying to build a hierarchical tree and display it in a page.
    The data I need to display is hierarchical.
    /A
    /B
    /A/1/a
    /A/2/k
    /B/1
    etc....
    I need to display the above data in a tree format. I am using Rational Application Developer.
    The problem is, I can t figure out in what way I have to store the data in the bean making it available to the page, and in what way I have to bind it to the faces tree - client component.
    Please help

    Reference your UIData component in the a backing bean.
    In the action event handler, for one of the columns,
    you can call UIData.getRowData() and it will return the object
    of the currently selected row data.

  • Bind Variables and Shared Component Report Query

    I have a query in a region report which I have replicated to a shared component report query.
    Both queries reference page items as bind variables in the where clause.
    The report region on screen shows the correct results but the report query shows "no data". This is the case when running "Test Query" and "Download XML data" from the shared component report query definition. If I hardcode the variable names I get rows returned, If I use bind variables - and specify the values for these variables I get no data. THe XML file contains the tags for each bind variable I have specified but has no data between the tags. I have Ticked the box to include application and session state but it appears that the bind variables are not being used.
    When I use my report query in the application (URL tied to a button) I get the same problem, the binds are not being passed to the report query.
    Can someone please clarify if this is a bug or not? And if not, how can I get it to work.
    I am using Apex 4.0.2
    Thanks
    Kathryn

    Hi
    To confirm, yes I selected the bind variables. I used these in the report layout, but the xml file has them as empty i.e.
    <P0_START_DATE><P0_START_DATE/> with nothing in between.
    IN the Test Query section, if I put real values in the boxes for the bind variables, I get no data found. If I hardcode the values into the query, I get the data.
    I've repeated the create report query many times and have created a report layout in RTF. I can use the layout with my region - in the print attributes and the layout works with the query but I need to create a PDF using 2 queries - ROWSET1 and ROWSET2. I can generate the XML but the values in the rows are all empty. When I use the layout with a report query instead of the region, I get no data even though I have used the same sql and have selected the bind variables. I was using variables from page items on page zero but have also tried using page items on the current page, the result is the same.
    I need to use a report query and a report layout as I need data from 2 queries in the PDF.
    I looked at your demo - what happens if you add a second sql query to the report query - is there any chance I can look at the back end (developer access?)
    Thanks for your input
    Kathryn

  • Issue in Binding Custom controller to Component Controller

    Dear All,
    I have enhanced a standard component ERP_H.
    I created a custom controller with context nodes BTSTATUS, BTSTATUSH
    I enhanced the component controller with context node BTSTATUS, BTSTATUSH
    Now when i try to bind the custom controller to component controller using this code in the context class of my custom controller
    bind to component controller
      owner->do_context_node_binding(
               iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
               iv_target_node_name = 'BTSTATUS'  " component controller context node
               iv_node_2_bind = BTStatus ).
    its not working since this context node in component controller is not the standard one but the custom added one.
    Am i missing something, or is there any way to bind customer context node in custom controller to customer context node in component controller.
    regards,
    pradeep

    Hi pradeep,
        Try the other way round go to the context class in the component controller and paste the following code in the
    create_contextnode( context node = name of the node to be linked).
    *owner->do_context_node_binding(
            iv_controller_type = cl_bsp_wd_controller=>co_type_custom   <-----linking from component to custom
            iv_target_node_name = 'BUILHEADER' "target node: component controller node
            iv_node_2_bind = BUILHEADER ). "source node: current node.
    See if this works.
    Thanks

  • Using bind variables in Shared Component Reports not working

    I've created a report query as a shared component in my APEX application. I'm calling the report on a page via a button. The query behind the report has bind variables for period and entity fields which are both defined on Page 0. I can run the query and return values just fine, but when you run the report from the page via the button, I get no values back. Does anyone know a trick to getting this to work? I've been working in APEX for about a month and I don't have much developer experience so any help is appreciated.
    Regards,
    -Steve

    Rohit,
    Thanks for your response. We are using APEX version 4.2.1.00.08. I do have Session State enabled and have put the required page items in the list. Here is my report query (highlighted lines contain the bind variables):
    SELECT TAX_DIVISION.DIVISION_CODE Division,
    TAX_ENTITY.ENTITY_CODE Entity_Code,
    DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4) Category_Desc,
    TAX_ADJUSTMENT.CLASSIFICATION Classification,
    TAX_ADJUSTMENT.ADJUSTMENT_CODE Adjustment_Code,
    SUM(NVL(NVL(TAX_ENTITY_ADJUSTMENT.OVERRIDE_AMT,TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_AMT),0)) Tax_Amount
    FROM TAX_DIVISION,
    TAX_ENTITY,
    TAX_ENTITY_ADJUSTMENT,
    TAX_ADJUSTMENT,
    TAX_PERIOD
    WHERE TAX_DIVISION.DIVISION_ID = TAX_ENTITY.DIVISION_ID
    AND TAX_ENTITY.ENTITY_ID = TAX_ENTITY_ADJUSTMENT.ENTITY_ID
    AND TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_ID = TAX_ADJUSTMENT.ADJUSTMENT_ID
    AND  TAX_ENTITY_ADJUSTMENT.PERIOD_ID = :P0_PERIOD_ID
    AND  TAX_ENTITY_ADJUSTMENT.YEAR_ID = :P0_YEAR_ID
    AND  TAX_ENTITY.DIVISION_ID = :P0_DIVISION_ID
    AND TAX_ADJUSTMENT.ADJUSTMENT_CODE = 'IBIT'
    GROUP BY TAX_DIVISION.DIVISION_CODE ,
    TAX_ENTITY.ENTITY_CODE ,
    DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4),
    TAX_ADJUSTMENT.CLASSIFICATION ,
    TAX_ADJUSTMENT.ADJUSTMENT_CODE
    HAVING SUM(NVL(NVL(TAX_ENTITY_ADJUSTMENT.OVERRIDE_AMT,TAX_ENTITY_ADJUSTMENT.ADJUSTMENT_AMT),0)) !=0
    ORDER BY DIVISION_CODE, DECODE(TAX_ADJUSTMENT.CATEGORY_DESC,'Net Income/(Loss)',1,'Permanent Adjustment',2,'Temporary Adjustment',3,4), CLASSIFICATION, ENTITY_CODE, ADJUSTMENT_CODE
    The query returns data when I set the bind variables and test in the report queries screen. When I assign the report query URL to the button in the application and run from there, I get no results.

  • Bind Data directly in Component in case of BEx?

    Hi Everyone,
    As per SAP tutorials, we can bind the data of universe query directly into Canvas Component means without the use of spreadsheet.
    But Can we bind the data of BEx query directly into component in dashboard 4.0??
    Please suggest your comments/views.
    Kind Regards
    Anukul

    Hi,
    Dimension,Display attribute, Exception will not support in Xcelsius
    Direct connector to SAP NetWeaver BEx queries
    Consume BEx Queries and Views
    Support of all variable type (incl. personalization)
    No limitations in queries features used
    BW authorization enforced
    Free characteristics list of values for filtering
    Best Regards
    Naveen

  • Dynamically binding backing bean

    Dynamic binding of backing bean
    Here is a problem that I have been trying to solve. Maybe someone can have a go at it:
    Here is a Search form(Simplified version):
    af:selectOneChoice - to choice a 'class family' e.g., companies, NGO, charity, institution etc
    af:inputText - to enter a name
    af:commandButton – to search
    Here is a User task:
    1.     Choose a 'class family' from the selectOneChoice
    2.     Enter a name in inputText
    3.     Click commandButton to start the search
    Additional information
    1. The number of 'class family' is about 30 and requires different method of search.
    2. I want to use a uniform search user interface and so there is only one page for all.
    3. Each 'class family' has it own managed bean in face-config.xml.
    Scenario:
    Lets say the searchUI.jsp has an initial backing bean called SearchBean.java. The af:selectOneChoice in searchUI.jsp has a valueChangeListener and when the user chooses a 'class family' at step (1), the valueChangeListener in SearchBean.java is triggered.
    Problem:
    The problem is how do I dynamically switch the backing beans, say from SearchBean.java to SearchCompanyBean.java so that when the user next click the search commandButton, it is the searchAction method in the SearchCompanyBean.java and NOT the initial SearchBean.java that handles the action.
    Cheers in advance.

    Hi,
    Assuming you are using ADF BC, have a look at using view criteria. You can define, dynamically apply and remove view criteria on the view object.
    Have a look at the help on oracle.jbo.ViewCriteria and applyViewCriteria from the ViewObject implementation class. Sounds like they might meet your requirements.
    Create a client method on your VO and drag it onto your page as an ADF parameter form and go from there.
    Brenden

  • Need to bind value attributes of Component controller with value attributes

    Hi,
    I am developing a Java Web Dynpro application which is importing RFC Model.

    Hi Kaushik,
    It is very simple to enter values in webdynpro and to update the ztable through RFC
    All you hav to do is
    1. Create the ztable , RFC to import data into that table,
    2. Create the model in webdynpro with that RFC
    3. First map the ModelInputElements to the component controller(say zid, zname) (you can have your own value attribute in component controller say id , name )
    4. Map the attributes to the view where the input field is there
    5. Now write the code as follows,
    Zxxx in = new Zxxx();
    wdContext.nodeZxx_InputElement.bind(in);
    in.setZid(wdcontext.currentContextElement().getId()); // getId component controllers attribute and getZid is model' s mapped attributre
    in.setZname(wdcontext.currentContextElement().getName()); // getName component controllers attribute and getZname is model's mapped attributre
    /* u need not have to map that model attrobute to component attribute for that */
    try
    in.execute();
    Catch(Eception e)
    e.printStackTrace();
    Regards,
    Sam Charles J.

  • DropDownList Binding From dictionary development component

    dear all
    i need the way to create dropdownlist UI component in webdynbro and bind its data from dictionary development component
    and what dependencies should we have between webdynpro component and dicitonary component
    regards tareq

    Hi
    Please have a look at this thread
    Using Dictionary Component in WD-Component
    Regards
    Saravanan K

  • Binding value nodes to component in a view

    Hi,
          What is the use of these value nodes and value attributes? How can I bind them to, say a inputfield in my view? Can any change to the value node dynamically affect the inutfield?

    Thanks to Peter Conrad for the answer. The answer's in a different post. I have included his reply below.
    From a binding perspective there's no difference between value or model nodes/ attributes. you can always bind using the syntax
    //<contextnode/attribute to the value attribute of the tag.
    And yes, for accessing the value the SET_<attribute> and GET_<attribute> methods should be used in this case.
    Peter
    Edited by: Arun Prakash Karuppanan on May 15, 2008 10:24 PM

  • Howto: portable bind, lookup remote + local beans (EJB3) to JNDI with WL 10

    I struggle writing portable ejb3 applications with weblogic.
    I have a JEE5 (EJB3) application using the standard and it works fine on JBoss and WebSphere.
    Porting it to Weblogic (10.0) there are quite a lot of problems, mainly
    in the area of JNDI lookups of EJBs.
    So the issue is how to configure the JNDI-Names of local and remote beans (EJB3!)
    in a portable way with Weblogic without making the application unportable.
    The biggest problem is caused by the fact, that WL 10 does not bind the EJBs
    to the JNDI-tree by default. The bound name would not really be important (JBoss and WebSphere
    come up with a value that can easily be used for a generic lookup). Just any binding
    would be fine.
    So there has to be some extra step in order to get WL 10 binding a remote or local
    bean into the JNDI tree. Unfortunately none of them works/is acceptable in an portable JEE app.
    Idea1: Using the "mappedName" attribute (of @Stateless, @Stateful)
    Well, this one is not portable as the documentation states:
    [http://edocs.bea.com/wls/docs100/ejb30/annotations.html#wp1417411|http://edocs.bea.com/wls/docs100/ejb30/annotations.html#wp1417411]
    Idea2: Using @weblogic.ejbgen.JndiName
    Using weblogic's annotation JndiName also doesn't bind the bean to the given names:
    @Stateless
    @weblogic.ejbgen.JndiName(local="myapp/XBean/local",remote="myapp/XBean/remote")
    public class XBean implements XLocal {
    Besides this, that code would not be portable (as nobody wants an weblogic.jar within another application server).
    Idea3: Using weblogic-ejb-jar.xml
    Mapping a bean using the weblogic-ejb-jar.xml below, also doesn't work.
    The bean is not bound to the given name "myapp/XBean/remote":
    Exception in thread "main" javax.naming.NameNotFoundException:
    Unable to resolve 'myapp.XBean.remote'. Resolved 'myapp.XBean' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'myapp.XBean.remote'. Resolved 'myapp.XBean']; remaining name 'remote'
    Looking at the JNDI tree, there is "something" bound to "myapp.XBean", but it is not the bean.
    Doing a lookup with this name ("myapp/XBean" or "myapp.XBean"), gives this:
    Exception in thread "main" java.lang.ClassCastException: weblogic.jndi.internal.WLContextImpl cannot be cast to test.server.XRemote
         at test.client.Client.main(Client.java:14)
    Question 1) What is the preferred way to bind and lookup a remote bean in Weblogic 10?
    Again: the goal is to use pure EJB3.
    Question 2) What is the preferred way to bind and lookup a local bean in WL 10?
    This lookup has to be done on the server in some "unmanaged" classes
    where injection doesn't work.
    If there is an unportable way to bind a local bean to jndi, it might do for the time.
    The important thing would be, that there is no weblogic specific code within the application.
    So, solving it using weblogic-xml files would be best.
    This declaration
    <local-jndi-name>myapp/XBean/local</local-jndi-name>
    will come up with the same problems, I guess.
    Here's the code. We want the local interface extending the remote interface,
    so that the local beans can do all what the remote beans can do too.
    XRemote.java
    package test.server;
    import javax.ejb.Remote;
    @Remote
    public interface XRemote {
    String JNDI_NAME = "myapp/XBean/remote";
    void doXRemote();
    XLocal.java
    package test.server;
    import javax.ejb.Local;
    @Local
    public interface XLocal extends XRemote {
    String JNDI_NAME = "myapp/XBean/local";
    void doXLocal();
    XBean.java
    package test.server;
    import javax.ejb.Stateless;
    @Stateless
    public class XBean implements XLocal {
    @Override
    public void doXLocal() {
    System.out.println("doXLocal() called");
    @Override
    public void doXRemote() {
    System.out.println("doXRemote() called");
    weblogic-ejb-jar.xml
    <weblogic-ejb-jar
    xmlns="http://www.bea.com/ns/weblogic/10.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>XBean</ejb-name>
    <jndi-name>myapp/XBean/remote</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    Client.java
    package test.client;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import test.server.XRemote;
    public class Client {
    public static void main(String[] args) throws NamingException {
    InitialContext context = getInitialContext();
    XRemote xRemote = (XRemote) context.lookup(XRemote.JNDI_NAME);
    xRemote.doXRemote();
    private static InitialContext getInitialContext() throws NamingException {
    Properties properties = new Properties();
    properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
    properties.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    properties.put(Context.SECURITY_PRINCIPAL, "weblogic");
    properties.put(Context.SECURITY_CREDENTIALS, "weblogic");
    return new InitialContext(properties);
    }

    Hi,
    about how to specify jndi name of remote ejb, please refer to this link: http://forums.oracle.com/forums/thread.jspa?threadID=800314&tstart=1
    please note @JNDIName isn't an EJBGen annotation. its package name is weblogic.javaee.
    So far, based on the EJB spec, local ejb will not be bound to global JNDI. EJB3.1 specification is trying to specify the portable JNDI names including local EJBs, but it isn't published yet.
    local EJB is used within one application and ejb reference is used to lookup the local EJB. please refer to EJB specification about how to declare an EJB local reference. once it is declared, it can be looked up from the java:comp\env JNDI namespace.
    But, if the local client of the EJB isn't a JavaEE component, there won't be any declaration of ejb-local-ref. You may want to try remote access to the EJB from the non-JavaEE client.

Maybe you are looking for