How to access/identify components in JSF Declarative Components?

Hi,
I am beginner on ADF. Trying to build first Declarative Components.
Use Case is as follows -
I have put 2 InputTexts in Declarative Component.
Want to set some value in second InputText (txtAddressLine2) in Validator/ValueChangeListner method of first InputText(txtAddressLine2).
<?xml version='1.0' encoding='windows-1252'?>
<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=windows-1252"/>
<af:componentDef var="attrs" componentVar="component">
<af:xmlContent>
<component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">
<display-name>Test</display-name>
<attribute>
<attribute-name>
AddressLine2
</attribute-name>
<attribute-class>
java.lang.String
</attribute-class>
</attribute>
<component-extension>
<component-tag-namespace>Address3</component-tag-namespace>
<component-taglib-uri>/Address3</component-taglib-uri>
</component-extension>
</component>
</af:xmlContent>
<af:inputText label="Address Line 1"
binding="#{backing_Address3.txtAddressLine1}"
id="txtAddressLine1"
validator="#{backing_Address3.txtAddressLine1_validator}"
autoSubmit="true" immediate="true" rendered="true"
valueChangeListener="#{backing_Address3.txtAddressLine1_valueChangeListener}"/>
<af:inputText label="Address Line 2" binding="#{backing_Address3.txtAddressLine2}"
id="txtAddressLine2"
validator="#{backing_Address3.txtAddressLine2_validator}"
autoSubmit="true" immediate="true"/>
</af:componentDef>
<!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_Address3-->
</jsp:root>
This is sample I am working on.
I am trying following approaches in bean of Component itself.
Approach I: This does not give any error, value is not set in txtAddressLine2
this.getTxtAddressLine2().setValue("Some Value");
Approach II: Not able to access txtAddressLine2 using findComponent() method
UIViewRoot uiViewRoot = facesContext.getViewRoot();
RichInputText inputText;
inputText = null;
if (uiViewRoot.findComponent("txtAddressLine2") != null) {
System.out.println("Found ");
inputText = (RichInputText)uiViewRoot.findComponent("txtAddressLine2");
inputText.setValue("my value");
} else {
System.out.println("Not Found "); //Always not found
Can anybody tell me correct way to access components and set their values inside Declarative Components itself?

Thanks buddies....its resolved!
This is how I have done it -
Components have these 2 Input Texts :
<af:inputText label="Label 1" id="txt1" autoSubmit="true" immediate="true"
binding="#{DC2.txt1}" validator="#{DC2.txt1_validator}"/>
<af:inputText label="Label 2" binding="#{DC2.txt2}" id="txt2"
immediate="true" autoSubmit="true" partialTriggers="txt1"/>
Code in Component Bean setting value is as follows:
RichInputText txt22;
txt22 = getTxt2();
txt22.setSubmittedValue("Some Value");

Similar Messages

  • How to access graphic components from classes?

    Hi,
    I am creating a Flex application. In my Main.mxml, I add
    different UI elements, such as panels. I also have a few
    actionscript files. Everything is in the same folder. So my
    question is : how can I access a panel created in Main.mxml from an
    actionscript class ? By accessing the panel, I mean things like
    change its properties, etc. Is it possible to access those in a
    'Flash-like' way, using something like _root.myPanel, or is it only
    possible through passing parameters?

    Well...it pains me to see someone obviously new to programming struggle here...so I'll take this one on:
    Here is the BAD way to do it...but it is basically what you are looking for...to learn GOOD ways to do this, please invest in some programming books and learn about encapsulation, MVC, and other programming/architectural styles...anyways...here is the BAD, but easy way:
    In your SGui class, right after the constructor you have to "declare" your object reference as a class member, so edit your file to make it say:
    public class SGui {
         public JButton addStickButton;Then, edit the line in SGui that says:
    final JButton addStickButton = new JButton();so that it just says:
    addStickButton = new JButton();Then, in your Soft class, you can access it just the way you wanted to in your comment:
    gui.addStickButton.setEnabled(false);Other Java programmers reading this thread will probably shoot me for showing you how to do it this way, because it violates principles of encapsulation...but go ahead and use it so you can move forward...but study a little more online or in books to get the hang of it :)
    Message was edited by:
    beauanderson
    Message was edited by:
    beauanderson

  • How to access unamed components

    If I had a frame with 100 text fields which was added to the frame using the following loop. How can I access and identify individual textfields
    for (int i=0;i<100;i++)
       someframe.add(new JTextField());
    }Any help is appreciated

    You could do something like the following:
    for (int i=0;i<100;i++)
    someframe.add(new JTextField(),setName("someUniqueName"));
    code]But that would require searching through the list of fields in the container looking for the correct field (not efficient).
    I suggest using the array suggestion. Or if you don't want to index them numerically, you could use a hashmap and map then to specific names.

  • How to Access MXML components  from ActionScript class

    Hi ,
    I am having a Application Conataner , in which i am having a Form Container with some Label in it .
    This is some thing similar to this as shown :
    <Mx:Application>
    <Mx:Form>
    <Mx:Label text="Hello world"/>
    </Mx:Form>
    </Mx:Application>
    Can any body please let me know how can i access this Form's Label , from an ActionScript class .
    catch(error:*)
    // Here i want to access these Objects and set data to that Label .
    Basically My requirement is that iinside the catch block of my ActionScript class , i want to set some text to the Label , Please
    let me know if this is possible or not also ??
    Waiting for your Replies .

    Hi these both are not same these refer to different one...
    Well let me explain...
    Application.application.myCustomComp.myLabel.text = "sometext"; sets the label "myLabel" which is present inside your customcomponent(which is in main application).
    Application.application.myLabel.text = "sometext"; sets the label "myLabel" which is present directly inside your main application.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Label id="myLabel"  text=""/> // So inorder to set the label(myLabel) present here you will use directly the 2nd line of code.
    <mx:CustomComp id="myCustomComp" /> // So inorder to set the label(myLabel) present inside this component you use 1st line of code.
    </mx:Application>
    Hope now its clear.
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • How to access UI components in event handler

    Hi
    How can I access all or a particular UI component's object in my event handler of a event which is not caused by that UI component which is being accessed.

    You need variable resolution:
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    WaferMap waferMap = (WaferMap)application.getVariableResolver().resolveVariable(context, "waferMap");or you can ask the event for ones near by
        //action from an h:commandLink
         public void seeMore(javax.faces.event.ActionEvent event)
           System.out.println("action: seeMore "+((HtmlCommandLink)event.getSource()).getAttributes());
            java.util.List map=((HtmlCommandLink)event.getSource()).getChildren();
            Iterator i=map.iterator();
            System.out.println("action: seeMore ");
            while(i.hasNext())
                Object obj=i.next();
                if(obj instanceof UIParameter)
                    UIParameter param=(UIParameter)obj;
                    System.out.println("\t seeMore "+param.getValue()+" ");
        }

  • Movie Themes: How to access individual components

    After playing around with PRE7's "Themes" functions (which I gather is also called "instant movie"?), and unbundling the instant movie into individual, editable elements, I was wondering if there's a way to access the sound effects and graphics used by instant movie.
    For example, I used the "Extreme Sports" theme. After unbundling the instant movie, some of the video transitions I recognized from the standard Effects or Transisions folders of the Edit panel.
    But other video effects (e.g. the "opening/closing credit" moving graphic) and sound effects (e.g. "explosion" or "glass shattering") I don't remember seeing anywhere.
    Am I missing something, or are some of the video/audio effects that are only available by applying then unbundling the instant movie?
    Thanks!!
    Ed

    Not yet.
    I first wanted to make sure there wasn't some way in PRE to do it, like a "sound effects" tab or something I wasn't seeing.
    If it turns out that there isn't, then my next stop was certainly to start poking around to see if I could import them as distinct items.
    If that's the case, I may just create my own "effects" folder and import everything I can find. Kind of create my own effects tab, in effect.

  • How to access the jpanel and other components on click of a button

    hi ,
    need help,how to access the components of a frame onclick of a button ,if the actionPerformed() is written in a seperate class.
    in my code
    button.addActionListener(new Xyz());
    Xyz is implementing the ActionListener.
    in actionPerformed() i want to access the components in the frame.
    thanks.

    public class Xyz implements ActionListener{
      JFrame frame;
      Component[] comps;
      public Xyz(JFrame f){
        frame = f;
        comps = frame.getContentPane().getComponents();
      public void actionPerformed(ActionEvent e){
        // access elements in comps array
    button.addActionListener(new Xyz(this)); // if 'this' is a JFrame in question

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • How to list/access swing components?

    hi all,
    Can anyone give me a clue, how can I access or simply list swing components I have on a frame, long after I created them. E.g. I'd like to change their setEnabled() attribute at a later time, not at creation time, but I don't know how to access them.
    Does Swing/AWT/JFC provides a component hierarchy? can someone share some code on this issue?
    Thanks for any help.
    Thomas

    I guess, you are saying the use of getComponent(int n)?
    Since I'm a beginner in Swing see my short code below:
    import java.awt.BorderLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTextArea;
    public class EasyFrame {
        public EasyFrame() {
            super();
            startHere();
        public void startHere() {
            JFrame frame = new JFrame("SwingApplication");
            JButton button = new JButton("click here");
            JTextArea area = new JTextArea();
            frame.setSize(300, 200);
            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(area, BorderLayout.CENTER);
            frame.getContentPane().add(button, BorderLayout.SOUTH);
            area.setText("Hello World");
            JMenuBar menuBar = new JMenuBar();
            JMenu menu = new JMenu("A Menu");
            menuBar.add(menu);
            JMenuItem menuItem = new JMenuItem("A text item");
            menu.add(menuItem);
            menu.addSeparator();
            menuItem = new JMenuItem("hello");
            menu.add(menuItem);
            JMenu subMenu = new JMenu("submenu");
            menuItem = new JMenuItem("sub1");
            subMenu.add(menuItem);
            menuItem = new JMenuItem("sub2");
            subMenu.add(menuItem);
            menu.add(subMenu);
            frame.getContentPane().add(menuBar, BorderLayout.NORTH);
            frame.show();
         public static void main(String[] args) {
         EasyFrame ef = new EasyFrame();
    }If I make a System.out.println(frame.getContentPane().getComponentCount());I get 3. But I should dig deeper (with getComponent(2)) to access JMenuBar. But this way I receive a AWT Component / not a JMenuBar Swing component to get its JMenu / and its JMenuItems. And I cannot make it cast to JMenuBar since this walk-through routine should be a universal while(isThereMoreCompenent){} procedure, I don't know when to cast to what (JMenu, JMenuItem, Button and so on).
    My problem is that how can I access the JMenuItems one by one, and change e.g. the setEnabled attribute of the "hello" menu?
    I hope you can make it clear to me.
    Please help if so.

  • How to access OS User created with "identified externally"

    I am able to
    SQL> create user ops$deskuser identified externally;
    while deskuser is one of my OS user.
    I believe it is a very easy question, however I just do not know how to access this user from sqlplus., please help
    Thanks in advance

    oracle@mini:~> sqlplus system
    SQL*Plus: Release 10.1.0.3.0 - Production on Sun Nov 13 21:11:47 2005
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> create user ops$pops identified externally;
    User created.
    SQL> grant connect to pops;
    Grant succeeded.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    oracle@mini:~> su - pops
    \Password:
    Illinois isn't exactly the land that God forgot -- it's more like the
    land He's trying to ignore.
    pops@mini:~> . oraenv
    ORACLE_SID = [pops] ? orcl
    pops@mini:~> sqlplus /
    SQL*Plus: Release 10.1.0.3.0 - Production on Sun Nov 13 21:16:59 2005
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>

  • How can I access/identify the linked subreport parameter fields?

    In my report, I have subreports, which have linked SQL parameters.  How can I identify these linked parameters, and what they are linked to in code?
    Thanks.

    reportClientDoc.SubreportController.GetSubreportLinks("<subreport name>").GetSubreportLinks()<i>.MainReportFieldName and
    reportClientDoc.SubreportController.GetSubreportLinks("<subreport name>").GetSubreportLinks()<i>.SubreportFieldName
    Where i is the ith linked parameter and is indexed from 1.
    Hope this helps.
    Thanks
    Aasavari
    Edited by: Aasavari Bhave on Feb 15, 2011 11:05 AM

  • Accessing interface components from a seperate class

    Hi there,
    I've just been given a Java project to build, that involves writing an applet to allow text based communication between pairs of people. I've always thought the best way to go about it was to divide code into functional units, i.e. put the user interface code in one class and the code that responds to user interface interactions in other classes (of the same package).
    The problem is getting the other classes to access the interface components created in the interface class.
    So for brevity, here is my interface Applet class;
    package name;
    import statements here;
    public class Communicate extends Applet {
    declare all variables, strings, labels, combo boxes etc
    //Construct the applet
    public Communicate() {
    try {
    jbInit();
    } catch (Exception ex) {
    ex.printStackTrace();
    //Initialize the applet
    public void init() {
    try {
    jbInit();
    } catch (Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    add components here
    //Now the problem. In the interface there are combo boxes. When the user clicks a button it constructs a jframe that asks the user for a string. The idea is that the string be added to a combobox using add item. If I leave this code in the applet class it works fine, e.g.
    public void jButton5_actionPerformed(ActionEvent actionEvent) {
    JFrame f = new JFrame();
    f.setSize(200, 200);
    f.setLocation(200, 200);
    f.setVisible(false);
    //Add those boxes to the JFrame
    JTextField titleField = new JTextField();
    String title = "Please enter the title";
    int result = JOptionPane.showOptionDialog(f,
    new Object[] { message },
    "New title", JOptionPane.OK_CANCEL_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null, null, null);
    String title = titleField.getText();
    jComboBox2.addItem(title);
    //as jComboBox2 is decalred in the applet above, it adds the string no problem.
    But what I'd like is the following, a title class on its own to make it easier to update and modify,
    e.g.
    public void jButton5_actionPerformed(ActionEvent actionEvent) {
    try {
    Title title = new Title();
    catch (Exception ex) {
    ex.printStackTrace();
    with the Title class written as such:
    package name;
    import statements;
    class Title {
    Title() {
    //Set the new title
    JFrame f = new JFrame();
    f.setSize(200, 200);
    f.setLocation(200, 200);
    f.setVisible(false);
    //Add those boxes to the JFrame
    JTextField titleField = new JTextField();
    String title = "Please enter the title";
    int result = JOptionPane.showOptionDialog(f,
    new Object[] { message },
    "New title", JOptionPane.OK_CANCEL_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null, null, null);
    String title = titleField.getText();
    *** Here is the problem: How do I reference jComboBox2 which is declared in the original applet class?
    jComboBox2.addItem(title); (this wont work!)
    public static void main(String[] args) {
    Title title = new Title();
    I'd thought perhaps I needed to create an instance of the applet and pass it to the second class to use it, so it can reference the components, but I'm not sure how to do this with an applet.
    Thanks
    Maria

    I'm not going to look at your unformatted code, but I'll give you some general hints:
    Have one set of classes being the GUI
    Have one set of classes being the data (the chat history, basically)
    Have one set of classes being the logic
    Have one interface for the logic to manipulate the data (e.g. addNewMessage(String)
    Have one interface for the GUI to get the data that's to be displayed (e.g. getLastTenMessages())
    Have one interface for the logic to notify the GUI of changed data (refresh())
    Have one interface for the GUI to notify the logic of user input (e.g. sendMessage(String))
    The logic will receive data either from the user and send it, as well as storing it in your chat log, or it will receive it from the network and add it to the data model, both times notifying the GUI of changes afterwards.

  • How to access and display a Web Service from a WSDL in JSP or JSTL ?

    Dear All,
    We need to access a Web Service which is hosted as WSDL How to access a WSDL file from JSP or JSTL, parse and display the SOAP response in JSP page.
    Any simple example or URL as reference to an example will be useful for me.
    It seems io tags of jakarta is able to send soap message, but how to display it in JSP.
    Yours,
    Sankar.B

    Dear Sir,
    Yes. I would like to know more about the Forte and how to consume WSDL file from JSTL. The following are my querirs.
    1. How to connect the declared JNDI from a JSP page. i.e: the Datasource - ex: booksDS
    2. We connect the Tomcat server using JNDI as jdbc/scott. But, if I give jdbc/scott in JSTL as datasource={jdbc/scott}, we could not able to connect. We use the following code in a JSP page to connect the DB from a JSP page. (Its quite easy to modify, so we use the connection in a JSP page.)
    3. How to Consume a WSDL url from JSTL. Ex: If there is a URL : http://localhost/ws/MathService.asmx?wsdl OR http://www.xmethods.com/test/BabelFish
    4. How to display the result. We tried via SOAP from io taglib of Jakarta, but gives us an SOAP (it also looks like xml) response. But, how to use the value from that soap response in IE client thru JSTL/JSP.
    5. Whether this JSTL tool will be available with Forte Enterprise/Community Edition. If so EE, whats the price.
    Please Reply Immediatly. We tried, trying, going to try to display a wsdl response, but not able to display in IE thru JSP/JSTL. But, weve tested the www.gotdotnet.com examples of asp.net web services, we are thru. Its quite easy it seems in .NET. But, we feel whether even there is not even one example in JSTL/ Java Web Services Dev. Pack to utilise a web service in full cycle. The example which uve given is thru servlets. We dont use servlets. Cos, its very easy to edit JSP pages, instead of compiling the serv. and using it.
    I hope ull reply for all the above queries, since ur from SUN.
    Expecting your fav. reply.
    Yours,
    Sankar.B

  • How to access variables from other class

        public boolean inIn(Person p)
            if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
                 return true;
            else
                 return false;
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
    here am trying to compare the existing object with another object.
    could you please tell me how to access the variables of other class because i meet this error?
    name cannot be resolved!
    thank you!

    public class Person
        protected String name; 
        protected char gender;      //protected attributes are visible in the subclass
        protected int dateOfBirth;
        protected String address;
        protected String natInsceNo;
        protected String phoneNo;
        protected static int counter;//class variable
    //Constractor Starts, (returns a new object, may set an object's initial state)
    public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
        dateOfBirth = howOld;
        gender = sex;
        name = nme;
        address = addr;
        natInsceNo = ins;
        phoneNo = phone;
        counter++;
    public class Store
        //Declaration of variables
        private Person[] list;
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             list = new Person[max];//size array with parameters
             maxSize = max;
             count = 0;
        }//end of store
    //constructor ends
    //accessor starts  
        public boolean inIn(Person p)
           return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

  • How to access variables??

    how to access public variables of any other class??
    suppose i have a file temp.java file ..& i know all the public variables. and
    i want to access the variable of those temp.class file which extends JApplet or Applet..
    and as u know it will declare public void init() .. & in this function only all declaration will be there.
    so now how to invoke this init() function from any mymethod()..to access public variables...

    its not working. for me..
    the variable which i m trying to access is non static.. its displays the error :
    Exception in thread "AWT-EventQueue-1" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
    and by one method i have connected database also.. and it has been called from init()..
    i have collected the data from the database..and i m storing the data in one ArrayList ..
    and i want to access that ArrayList..

Maybe you are looking for

  • Satellite Pro A200 doesn't charge if running

    Hello I have a new Toshiba Satellite Pro A200 running Vista. I have a problem with the mains adapter and charging. It will boot up and operate fine, and when switched off will charge the battery on mains fine. But when switched on, the machine automa

  • A/P Invoice and BaseRef(Purchase Order) as parameter of function

    Every time i add row in A/P Invoice need to fire some function using formatted search where one of the parameter is BaseRef(DocNum) of the Purchase Order. So lets say formatted search is connected with Price and looks like this: SELECT dbo.example("B

  • Substitution in portal UWL

    Hi I had a question around the portal UWL, and I've tried SDN, SAP Help, Google, and still can't find a definitive answer; so I'm hoping someone here can help. We run EP6 with an ECC5 backend, and our users are allowed to manage substitution via the

  • PowerMac G4 (AGP) and HD LCD Monitor

    I gave my daughter a few years ago my old G4 PowerMac (AGP Graphics) which has a VGA port and is connected to a huge Apple 17" CRT Studio Display. I'd like to give her a modern LCD display. The HP 2009M HD LCD Monitor states that it comes with a stan

  • EOIO,Maintain order at run time

    Hi,   I've query about EOIO and Maintain order at runtime option under these 2 situations how PI will behave 1. If 5 records are processing under 1 file and if 3 rd record fails then rest 4,5 records will process or not? 2. If 5 files are processing