KeyEvent on dynamically generated Buttons

hi,
I have an app, which builds <n> number of buttons reading from an XML file.
Below is the code that generates the buttons
     for (int i=0; i<strBtnValue.length; i++) {
        btn[i] = new Button(strBtnValue[1]);
btn[i].setForeground(getColor(strBtnForeground[i][1]));
btn[i].setBackground(getColor(strBtnBackground[i][1]));
btn[i].setBounds(intX_btn, intY_btn, intW_btn, intH_btn);
intX_btn = intX_btn + 140;
btn[i].setFont(strBtnFont);
btn[i].addKeyListener(this);
add(btn[i]);
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == 68) { // key D is pressed
System.out.println("Released D");
}I need to assign 'keyboard D' to a button.  And when 'D' is pressed, i want to get the attributes for that button.  Could anyone shed some light ? Let me if this is not a clear explanation.
Thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

In the future Swing questions should be posted to the Swing forum: http://forum.java.sun.com/forum.jspa?forumID=57
Your mistake is that you are using KeyListener - this is only valid if you want to listener to the keyboard when the component has focus.
Instead, you should set a mnemonic: http://java.sun.com/javase/6/docs/api/javax/swing/AbstractButton.html#setMnemonic(int)
Or work with keyboard bindings: http://java.sun.com/products/jfc/tsc/special_report/kestrel/keybindings.html

Similar Messages

  • KeyEvent on dynamically generated Buttons - AWT

    hi,
    I have posted the below in Swing forum and was adviced to post this type of questions in AWT forum. I got a solution jbutton.setMnemonic(int keycode) and that can be used only in JButton, I believe.
    Is there anything similar we can use in Button. Below is the post. Could someone please help ?
    I have an app, which builds <n> number of buttons reading from an XML file.
    Below is the code that generates the buttons
      Button btn[];
         for (int i=0; i<strBtnValue.length; i++) {
            btn[i] = new Button(strBtnValue[1]);
    btn[i].setForeground(getColor(strBtnForeground[i][1]));
    btn[i].setBackground(getColor(strBtnBackground[i][1]));
    btn[i].setBounds(intX_btn, intY_btn, intW_btn, intH_btn);
    intX_btn = intX_btn + 140;
    btn[i].setFont(strBtnFont);
    btn[i].addKeyListener(this);
    add(btn[i]);
    public void keyReleased(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == 68) { // key D is pressed
    System.out.println("Released D");
    }I need to assign 'keyboard D' to a button. And when 'D' is pressed, i want to get the attributes for that button. Could anyone shed some light ? Let me if this is not a clear explanation.
    Thanks in advance.
    Edited by: Sathanga on Feb 13, 2008 7:00 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Is this what you're looking for?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ButtonTest extends JFrame implements KeyListener {
         public ButtonTest() {
              JPanel cp = new JPanel(new BorderLayout());
              Button b = new Button("Button 1");
              b.addKeyListener(this);
              cp.add(b, BorderLayout.LINE_START);
              b = new Button("Button 2");
              b.addKeyListener(this);
              cp.add(b, BorderLayout.LINE_END);
              setContentPane(cp);
              setTitle("Button Test");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              pack();
         public void keyPressed(KeyEvent e) {
         public void keyReleased(KeyEvent e) {
              if (e.getKeyCode()==KeyEvent.VK_D) {
                   Button b = (Button)e.getSource();
                   String buttonText = b.getLabel();
                   System.out.println("'D' key released for button: " + buttonText);
         public void keyTyped(KeyEvent e) {
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        new ButtonTest().setVisible(true);
    }

  • Add an action listener to a dynamically generated button...

    The use case is that i generate programatically some RichCommandButton(it's oracle ADF) and wanna associate with that button a method (as i do statically in .jspx [actionListener="#{method that has ActionEvent as parameter}"])...
    Problem is that i get {code}java.lang.IllegalArgumentException: wrong number of arguments{code} when i press the button...
    My code is as follows:
    {code}
    RichCommandButton closeBtn = new RichCommandButton();
    closeBtn.setText("X");
    // next to bind it to an action
    FacesContext faces = FacesContext.getCurrentInstance();
    Application app = faces.getApplication();
    ExpressionFactory ef = app.getExpressionFactory();
    MethodExpression me =
    ef.createMethodExpression(faces.getELContext(),
    "#{backingBeanScope.backing_untitled1.remove}",
    Object.class,
    new Class[] { ActionEvent.class });
    closeBtn.setActionExpression(me);
    // Add components
    toolbar.getChildren().add(closeBtn);
    {code}
    and the remove method is :
    {code}
    public void remove(ActionEvent actionEvent) {
    // Add event code here...
    System.out.println("s-a declansat remove");
    {code}
    Can anyone help with this... it more JSF than ADF...
    thanks,
    kquizak

    You need UICommand#addActionListener() rather than UICommand#setActionExpression().

  • Generating buttons and listboxes dynamically on the screen

    Hi people!!
    There's a way to generate buttons and listboxes dynamically on the screen????
    Tks in advance
    Gabriel

    hi check this..
    Dynamic drop down list box

  • Generate buttons dynamically

    Is there a way to generate buttons (or other items) dynamically (at run time) using Forms 10g? I am aware of the common technique of creating multiple items and manipulating their visibility dynamically. I'd like to know if there is a way to avoid this.
    Perhaps there is a way to do it through Java plug-ins. But I am not familiar with Java, so I am mostly interested in native Forms methods.
    I know there is a way to do it in Access, so perhaps Forms have it as well.
    Thank you!

    How flexible are java beans?In general, java-beans in forms are used to enhance the functionality or add some piece of UI-experience which is not standard in forms. So the question is, what functionality are you missing for a "pure" forms-solution?
    perhaps you have experience with both jdeveloper and java-beansYes i do, but thats comparing apples to peaches. JDeveloper is a tool to write any kind of java-applications, java-beans in the sense of forms are "widgets" you can use inside a forms-application.
    What kind of application do you want to develop? Is is data-driven, is it a graphical application?
    What are the requirements for it? Does it have to be web-based, will be used in intranet and/or internet?
    Do you already have forms-applications and the infrastructure you need for it (such as an application server)?
    There are a lot of questions which can lead to a decision for forms or any other kind of application-architecture.
    Most items on my interface will be non-database controls. They will serve mostly to enter parameters and launch stored procedures.So they are static dialogs ? Why then the need for java-beans?

  • Many times dynamic generate UIElement  at Runtime ???

    Hello Everyone,
    I wanna generate a UIElement (InputField) at runtime. When man click a button "Add InputField", then a UIElement (InputField) is dynamic generated. Man can generate many times UIElement"InputField" with this button.
    I have tried the Webdynpro Tutorial 17. But not yet any idea.
    Plx give me some suggestions and code.
    Thanks in advance
    best regards
    Yaning

    hi
    for this create 2 int variables <b>act</b> and a <b>counter</b>
    //@@begin others
      static int act,counter=0;
      //@@end
    <b>in Doinit set act to 0.</b>
    public void wdDoInit()
        //@@begin wdDoInit()
        act=0;
        //@@end
    <b>create an action(onActionCreate_Element) and assign it to the button ui element</b>
    public void onActionCreate_Element(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCreate_Element(ServerEvent)
        act = 1;
        //@@end
    <b>in wdDoModifyView</b>
    public static void wdDoModifyView(IPrivateDynamicView wdThis, IPrivateDynamicView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
        if( act== 1)
             IWDTransparentContainer con= (IWDTransparentContainer)view.getElement("RootUIElementContainer");
             IWDInputField input = (IWDInputField)view.createElement(IWDInputField.class,"input1"+counter);
             IWDAttributeInfo test = wdContext.getNodeInfo().addAttribute("name"+counter,"ddic:com.sap.dictionary.string");
             input.bindValue(test);
             input.setVisible(WDVisibility.VISIBLE);
             counter++;
             con.addChild(input);
                    act = 0;
        //@@end

  • Cross column radio group solution using dynamically generated HTML

    I am tasked with creating a screen in Apex matching look and feel of an existing application screen; tabular form, multiple column radio buttons to update a single column value (radio group needs to be row oriented, across multiple columns). I could not find a way to use HTMLDB_ITEM.RADIO_GROUP () function for this due to the radio group being column based, great as a row selector but not for use across columns (each button being a column).
    My first thought was to comprise and use checkboxes via HTMLDB_ITEM.CHECKBOX () for the multiple choices (in each column) and HTMLDB_ITEM.HIDDEN() to hold the chosen value, a JavaScript function for “onClick” event to make the checkboxes in one row act like radio buttons in a radio group. I created a simple application to show the concepts of my solutions …
    SQL looks like this:
    select pk_id, -- f01
    object_to_color, -- f02
    HTMLDB_ITEM.CHECKBOX(11, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f11, ''RED'')"', 'RED') red,
    HTMLDB_ITEM.CHECKBOX(12, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f12, ''BLUE'')"', 'BLUE') blue,
    HTMLDB_ITEM.CHECKBOX(13, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f13, ''GREEN'')"', 'GREEN') green,
    color_choice -- f03
    from objects_to_color
    Columns pk_id and color_choice are set as Show off and Display As Hidden. Note that my HTMLDB_ITEM.CHECKBOX items start with id number 11 (f11 – f13) so as not to conflict with the item id’s Apex will generate on it’s own. I could have used HTMLDB_ITEM functions to create all items and had my own PL/Sql update process.
    This creates a tabular presentation with a column for each color choice as a checkbox, shown checked if that color is initially set.
    The JavaScript function chkboxAction() clears the other checkboxes if a color is selected and stores the color in the hidden item db column for use in Apex Submit processing. Sorry the identation get's lost in the post!
    function chkboxAction (id, ckbx, color) {
    // f01 is pk_id (hidden)
    // f11 is RED checkbox
    // f12 is BLUE checkbox
    // f13 is GREEN checkbox
    // f03 db column color_choice for update (hidden)
    var idx;
    // Find row index using pk_id passed in as id argument.
    for (var i=0; i < document.wwv_flow.f01.length; i++) {
    if (document.wwv_flow.f01.value == id) {
    idx = i;
    i = document.wwv_flow.f01.length;
    if (ckbx(idx).checked == true) {
    // Set hidden color_choice column value to be used in update.
    document.wwv_flow.f03(idx).value = color;
    // Uncheck them all, then reset the one chosen.
    document.wwv_flow.f11(idx).checked = false;
    document.wwv_flow.f12(idx).checked = false;
    document.wwv_flow.f13(idx).checked = false;
    ckbx(idx).checked = true;
    } else {
    // Unchecked so clear color_choice column value to be used in update.
    document.wwv_flow.f03(idx).value = '';
    This works well and, as an aside, has an added feature that the color can be “unchosen” by unchecking a checked checkbox and leaving all checkboxes unchecked. This cannot be done with radio buttons unless a radio button is added as “no color”.
    But what if radio buttons must be used, as in my situation? Here is another solution using custom code to dynamically generate radio buttons for a row based radio group rather than using HTMLDB_ITEM.RADIO_GROUP ().
    select pk_id, -- f01
    object_to_color, -- f02
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_1" value="RED" '||
    decode(color_choice, 'RED', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''RED'')">' red,
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_2" value="BLUE" '||
    decode(color_choice, 'BLUE', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''BLUE'')">' blue,
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_3" value="GREEN" '||
    decode(color_choice, 'GREEN', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''GREEN'')">' green,
    color_choice -- f03
    from objects_to_color
    The pk_id column is used here to ensure a unique name and unique id for the items. In practice a custom api should be used to generate items in this way.
    The JavaScript function is actually simpler for radio buttons because the radio group handles the mutually exclusive logic for choosing a color.
    function rbAction (id, color) {
    // f01 is pk_id (hidden)
    // f03 db column color_choice for update (hidden)
    var idx;
    // Find row index using evaluation_question_id.
    for (var i=0; i < document.wwv_flow.f01.length; i++) {
    if (document.wwv_flow.f01.value == id) {
    idx = i;
    i = document.wwv_flow.f01.length;
    // Set hidden result column referenced in update.
    document.wwv_flow.f03(idx).value = color;
    Now the problem is that on update, Apex will be confused by the custom items and try to post updated values to it’s own internal items – which don’t exist. The result is the very frustrating HTTP 404 - File not found error when apex/wwv_flow.accept executes on Submit. So, the trick is to clear the custom items prior to the update with a simple JavaScript function, then the values show again when the page is rerendered, if you are not branching from the page. The Submit button is changed to call the following function:
    function submit () {
    var items = document.getElementsByTagName("INPUT");
    for (i=0; i< items.length; i++) {
    if (items(i).type == "radio") {
    if (items(i).checked == true)
    items(i).checked = false;
    doSubmit('SUBMIT');
    This technique might have general use when using custom items. Comments or improvements on this?
    See Oracle Apex site: workspace SISK01, app OBJECTS_TO_COLOR

    Just the code for formatting.
    Checkboxes to behave like radio group ...
    SQL ...
    select pk_id,              -- f01
           object_to_color,    -- f02
              HTMLDB_ITEM.CHECKBOX(11, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f11, ''RED'')"', 'RED') red,
              HTMLDB_ITEM.CHECKBOX(12, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f12, ''BLUE'')"', 'BLUE') blue,
              HTMLDB_ITEM.CHECKBOX(13, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f13, ''GREEN'')"', 'GREEN') green,
           color_choice  -- f03
    from objects_to_colorJavaScript ...
    function chkboxAction (id, ckbx, color) {
        // f01 is pk_id (hidden)
        // f11 is RED checkbox
        // f12 is BLUE checkbox
        // f13 is GREEN checkbox
        // f03 db column color_choice for update (hidden)
        var idx;
        // Find row index using pk_id passed in as id argument.
        for (var i=0; i < document.wwv_flow.f01.length; i++) {
           if (document.wwv_flow.f01(i).value == id) {
              idx = i;
              i = document.wwv_flow.f01.length;
        if (ckbx(idx).checked == true) {
          //  Set hidden color_choice column value to be used in update.
          document.wwv_flow.f03(idx).value = color;
          // Uncheck them all, then reset the one chosen.
          document.wwv_flow.f11(idx).checked = false;
          document.wwv_flow.f12(idx).checked = false;
          document.wwv_flow.f13(idx).checked = false;
          ckbx(idx).checked = true;
        } else {
          //  Unchecked so clear color_choice column value to be used in update.
          document.wwv_flow.f03(idx).value = '';
    }Radio button solution ...
    SQL ...
    select pk_id,              -- f01
           object_to_color,    -- f02
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_1" value="RED" '||
                decode(color_choice, 'RED', 'CHECKED', '')||
                ' onClick="rbAction('||pk_id||', ''RED'')">' red,
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_2" value="BLUE" '||
               decode(color_choice, 'BLUE', 'CHECKED', '')||
               ' onClick="rbAction('||pk_id||', ''BLUE'')">' blue,
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_3" value="GREEN" '||
               decode(color_choice, 'GREEN', 'CHECKED', '')||
               ' onClick="rbAction('||pk_id||', ''GREEN'')">' green,
           color_choice  -- f03
    from objects_to_colorJavaScript ...
    function rbAction (id, color) {
        // f01 is pk_id (hidden)
        // f03 db column color_choice for update (hidden)
         var idx;
         // Find row index using evaluation_question_id.
        for (var i=0; i < document.wwv_flow.f01.length; i++) {
           if (document.wwv_flow.f01(i).value == id) {
              idx = i;
              i = document.wwv_flow.f01.length;
        //  Set hidden result column referenced in update.
        document.wwv_flow.f03(idx).value = color;
    function submit () {
      // Clears radio buttons to prevent Apex trying to post and causing page error.
      var items = document.getElementsByTagName("INPUT");
      for (i=0; i< items.length; i++) {
        if (items(i).type == "radio") {
          if (items(i).checked == true)
            items(i).checked = false;
      doSubmit('SUBMIT');
    }

  • Problem in Setting Focus, on a dynamically generated field

    Hi all,
    I am having a jsp page, in which I have dynamically generated n number of input text fields, and with the function onchange="chk();", and i am passing the current text field value, and 2 more parameters min and max.
    In function chk(), i am validating the input value by condition it should be within min and max..
    my problem is i want to[b] get back the focus to the input text box, where the input is entered and not satisfied my condtion
    function chk(a,b,c)  / /a is my i/p, b and c are min and max values
    if( (parseInt(a)>=parseInt(b)) && (parseInt(a)<=parseInt(c)) )
    document.form1.submit;
    return true
    else
    alert("Invalid Output");
    var element=event.srcElement.name;
    alert(element); // I am able to get the name of input text box
    alert(event.srcElement.tagName);  // this gives INPUT
    if(event.srcElement.tagName=='INPUT')
    alert("yes"); // i can get this alert
    event.srcElement.focus();  // the focus can't be set back to that input field or element
    return false
    }

    try this and say me if it works fine!!!
    <html>
    <head>
    <script>
    function fileds() {
         var myParent = document.getElementById('myDiv');
         var text = document.createElement('input');
         text.setAttribute('id', 'myText');
         myParent.appendChild(text);
         document.all.myText.focus();
    </script>
    </head>
    <body>
    <input type="button" onClick="javascript:fileds()" value="Create And Give Focus">
    <br>
    <div id="myDiv"></div>
    </body>
    </html>
    bye

  • Problem in dynamically generating the file upload field

    Hello all
    I am using netbeans 5.5 and visualwebpack for my jsf project.
    i have a problem in dynamically generating the file upload field and using it.
    I have a panel say "panelA" which holds file upload fields.
    Depending upon the count value i generate the file upload field using following code snippet:
    Upload upload1 = new Upload();
    upload1.setId("upload1");
    getPanelA.getChildren().add(upload1);
    The page successfully shows up the file upload fields. While the user clicks the submit button, i have used following logic to perform upload:
    List components = getPanelA().getChildren();
    for(int i = 0; i<components.size(); i++){
    if(components.get(i) instanceof Upload){
    UploadedFile uploadedFile = ((Upload)components.get(i)).getUploadedFile();
    I am getting this UploadedFile object null.
    How can i solve this problem.

    Anyway,
    I solved the problem.
    Actually i was using label property of the upload field due to which i got null pointer exception.
    I removed the label property of the upload field and things worked as i wanted.

  • Dynamically generating input grid

    I am trying to figure out a way to let users dynamically generate rows of input text boxes using a button in an HTML page e.g. user will enter text in say 10 columns and then hit enter, which will create another row of text boxes with same number of columns. Also all the text boxes should automatically generate their names e.g. if the column name is "Address" then the name of the first address text box in the first row should be e.g. "address_1" and then name of the second address text box should be e.g. "address_2".
    I want to do this on the client side, so that I can gather all the information and then only pass it on to the server.
    Any help would be greatly appreciated.
    Thx

    Depends on how you have build your JSP page. Assuming:
    1. You have built your .JSP with one or more .java files. Then the previous example that our friend answered you is write but converted into java code and not in javascript. In case you dont understand how you can build a JSP file with .java file i explain:
    you write Java code in a .java file but it has HTML tags. When your code is executed the tags are "created" because your code says so. And this is the way your .JSP is being built. In there you can create a sequence with for or anything else you figure out to build more and more lines. For the names figure out a generator method.
    2. You have built your code with another tool (Dreamweaver) and you dont want or know to use java code to create more lines. Then i suggest you a middle way:
    Figure out how many lines will be created from your users more or less. Let's say that more or less users create from 4-6 lines. Create your lines already, put names on them with a generator but have them disabled (type="textfield" ....... disabled>). Then use javascript so when the user wants to have more lines or rows allow with javascript the second row to be enabled and so on. When you reach your final line or row but the user still wants more lines, have a button saying "More" or sth like that and reload the page but be sure to store the previous entered values. I hope i helped.
    P.S. Maybe also try to change that by putting a textarea unless it doesnt help. Let me know what you think.

  • How to expose to test automation dynamically generated third party component

    We need to expose to test automation extended check box (which is not our component), that is dynamically generated and works together with tree.
    So, our application contains the  following code:
    import org.sepy.ui.CheckBoxExtended;
    checkBox = new CheckBoxExtended();
    Then all properties of check boxes are set dynamically.
    These check boxes are  used with the tree, to select  any of its nodes.
    When using test automation tool (we are evaluating RiaTest), automation tool agent sees the tree, but it does not see checkboxes, and therefore selection  of tree node cannot be automated.
    Is there any  way to make automation tool agent see this check box? There is a procedure for instrumenting custom components, but this is like third party component.
    Thanks,
    Miroslaw

    I am beginning to think that there is no solution to my problem. Let me better define the problem:
    1. Automation tool does not see extended check box.
    2. The container of extended check box is standard tree (nothing to instrument).
    3. Extended check box is third party component which was derived from standard button, and not standard check box (theoretically nothing to instrument again).
    4. Extended check box was used in item renderer class of the tree.
    Maybe elements used in item renderers cannot be exposed to automation tools (I have tried FlexMonkey and RiaTest, but they both failed)?

  • Dynamic radio button and group

    Hi, we have create dynamic radio button and group on “application creation complete” event , but which I am try to get number of radio button its show zero, see below code
    import flash.utils.setTimeout;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import spark.components.RadioButton;
    import spark.components.RadioButtonGroup;
    private var  rbg:RadioButtonGroup;
    private var  rb1:RadioButton;
    private var  rb2:RadioButton;
    private var dcount:int = 0;
    protected function application1_creationCompleteHandler(event:FlexEvent):void
         // TODO Auto-generated method stub
         // TODO Auto-generated method stub
         rb1 = new RadioButton();
         rb2 = new RadioButton();
         rbg = new RadioButtonGroup();
         rb1.label = "Radio1";
         rb2.label = "Radio2";
         rb1.group = rbg;
         rb2.group = rbg;
         vbox1.addChild(rb1);
         vbox1.addChild(rb2);
         checkRadioButton (); 
    protected function checkRadioButton ():void
         Alert.show("In checkRadioButton function : " +  rb1.group.numRadioButtons.toString());
    If I put some Time interval to call  checkRadioButton function its working fine,
    //checkRadioButton (); 
    setTimeout(checkRadioButton,1000);
    but this is not best practice.
    why this happen ….can anybody  clear  this or any other way to do this.
    Thanks in advance

    @manjeet.patel,
    Just write the below line of code
    vbox1.validateNow();
    You need not use setTimeout() function
    vbox1.addChild(rb1);
    vbox1.addChild(rb2);
    vbox1.validateNow();
    Thanks,
    Bhasker

  • Accesing dynamically generated UI elemnts using Automation tool

    Hi,
    I want to test my iOS app. It contains dynamically generated UI elemnts.
    I can't print them with logElementTree() and I don't know how to access the  dynamically generated elements.
    If there is any way I can access dynamically generated elements using a script?
    Any help will be highly apreciated
    Thank You and best regards
    Aruna

    I am beginning to think that there is no solution to my problem. Let me better define the problem:
    1. Automation tool does not see extended check box.
    2. The container of extended check box is standard tree (nothing to instrument).
    3. Extended check box is third party component which was derived from standard button, and not standard check box (theoretically nothing to instrument again).
    4. Extended check box was used in item renderer class of the tree.
    Maybe elements used in item renderers cannot be exposed to automation tools (I have tried FlexMonkey and RiaTest, but they both failed)?

  • Accessing Dynamically created Button

    Hi,
    Can someone give me an example how to access dynamically created button? 
    I know how to create a button dynamically but don't know how to access from AS3.
    Thanks!

    Hi,
    Please go through following links.
    1) http://www.daveoncode.com/2009/05/20/objectcollector-accessing-dynamic-generated-flex-obje cts-by-id/
    2) http://stackoverflow.com/questions/6740813/flex-assigning-events-to-dynamically-created-bu ttons
    3) http://www.justskins.com/forums/adding-click-event-to-35785.html
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • Making a dynamically generated field as Read Only

    Hi All,
    I am extending a standard CO and in that I wanted to make an entire table as read only. I checked by personalizing the page from front end, but as the items are dynamically generated fields , they are not visible in personalize page.
    So is there any way to cach these fields and make them read only programmatically.
    Thanks,
    Srikanth

    Hi Pratap,
    I have looked into the view source and took the name of a input type ( There is no ID for the field) and used it in findIndexedChild, but it returns a null. I guess this is happening is the current CO is a mere region level CO and it is not being given the access.
    The code in the class file is as follows :
    public static void processTable(OAPageContext oapagecontext, OAWebBean oawebbean)
    oapagecontext.startTimedProcedure("CrossTableCO", "processTable");
    String s = null;
    String s1 = null;
    int i = oawebbean.getIndexedChildCount();
    String as[[][]] = new String[7];
    int j = 0;
    String as1[[][]] = new String[i][6];
    for(int k = 0; k < oawebbean.getIndexedChildCount(); k++)
    UINode uinode = oawebbean.getIndexedChild(k);
    if(!(uinode instanceof OAMessageStyledTextBean))
    continue;
    OAMessageStyledTextBean oamessagestyledtextbean = (OAMessageStyledTextBean)uinode;
    if(oamessagestyledtextbean.isRendered())
    oamessagestyledtextbean.setRendered(false);
    oamessagestyledtextbean.setAttributeValue("benCustomBeanRender", "Y");
    if("TotalPlanLabel".equals(oamessagestyledtextbean.getUINodeName()))
    s1 = oamessagestyledtextbean.getLabel();
    continue;
    if(s == null)
    s = oamessagestyledtextbean.getViewUsageName();
    as[j][0] = oamessagestyledtextbean.getViewAttributeName();
    as[j][1] = oamessagestyledtextbean.getSortByAttributeName();
    as[j][2] = oamessagestyledtextbean.getLabel();
    as[j][3] = oamessagestyledtextbean.getExportByViewAttrName();
    as[j][4] = oamessagestyledtextbean.getDestination();
    as[j][5] = oamessagestyledtextbean.getUINodeName();
    as[j][6] = oamessagestyledtextbean.getDataType();
    if(as[j][4] != null && as[j][5] != null)
    as1[j][0] = as[j][5];
    as1[j][1] = as[j][0];
    as1[j][2] = s;
    as1[j][3] = as[j][4];
    as1[j][4] = as[j][6];
    as1[j][5] = as[j][3];
    j++;
    continue;
    if("TotalPlanLabel".equals(oamessagestyledtextbean.getUINodeName()))
    s1 = "XXHideXXTotalXX";
    oawebbean.setAttributeValue("CrossTableUpdateInfo", as1);
    oawebbean.setAttributeValue("CrossTableRenderCount", Convert.getString(j));
    if(s == null)
    return;
    OAViewObject oaviewobject = (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject(s);
    if(oaviewobject == null || !oaviewobject.isPreparedForExecution() || oaviewobject.first() == null)
    return;
    } else
    oawebbean.addIndexedChild(createTable(oawebbean, oaviewobject, as, j, s1));
    oawebbean.setAttributeValue("CrossTableRowCount", Convert.getString(oaviewobject.getRowCountInRange()));
    oapagecontext.endTimedProcedure("CrossTableCO", "processTable");
    return;
    private static UINode createTable(OAWebBean oawebbean, OAViewObject oaviewobject, String as[][], int i, String s)
    int j = oaviewobject.getRowCountInRange();
    DataTextNode datatextnode = new DataTextNode(new DataBoundValue("text"));
    String as1[] = new String[j + 1];
    CrossTableData acrosstabledata[] = new CrossTableData[i];
    int k = -1;
    for(int l = 0; l < i; l++)
    acrosstabledata[l] = new CrossTableData(new CrossTableCellData[j + 1]);
    for(int i1 = 0; i1 <= j; i1++)
    if(i1 > 0)
    try
    if(s != null && j > 1 && CT_NUM_MINUS_ONE.equals(oaviewobject.getRowAtRangeIndex(i1 - 1).getAttribute("GroupOiplId")))
    as1[i1] = s;
    else
    as1[i1] = (String)oaviewobject.getRowAtRangeIndex(i1 - 1).getAttribute("Name");
    catch(Exception exception)
    datatextnode = null;
    as1[i1] = "";
    if(k < 0 && j > 1 && "XXHideXXTotalXX".equals(s) && CT_NUM_MINUS_ONE.equals(oaviewobject.getRowAtRangeIndex(i1 - 1).getAttribute("GroupOiplId")))
    k = i1;
    for(int j1 = 0; j1 < i; j1++)
    if(i1 == 0)
    acrosstabledata[j1].getData()[i1] = new CrossTableCellData(as[j1][2]);
    else
    acrosstabledata[j1].getData()[i1] = new CrossTableCellData(null, as[j1][2], oaviewobject, i1 - 1, as[j1][0], as[j1][1], as[j1][3], as[j1][4], as[j1][5], as[j1][6]);
    TableBean tablebean = new TableBean("CrossTable", new ArrayDataSet(acrosstabledata), null, null, datatextnode, new ArrayDataSet(as1, "text"));
    tablebean.setWidth("100%");
    tablebean.setSummary(" ");
    tablebean.setNameTransformed(false);
    tablebean.setTableFormat(new DictionaryData("tableBanding", "rowBanding"));
    tablebean.setID((new StringBuilder()).append("CrossTable").append(oawebbean.getID()).toString());
    oawebbean.setAttributeValue("CrossTableId", tablebean.getID());
    DictionaryData adictionarydata[] = new DictionaryData[j + 1];
    Object obj = null;
    Object obj1 = null;
    for(int k1 = 0; k1 <= j; k1++)
    OAWebBean oawebbean1 = createColumn(k1);
    if(k1 == k)
    oawebbean1.setRendered(false);
    tablebean.addIndexedChild(oawebbean1);
    if(k1 == 0)
    adictionarydata[k1] = new DictionaryData("columnDataFormat", "textFormat");
    continue;
    try
    String s1 = (String)oaviewobject.getRowAtRangeIndex(k1 - 1).getAttribute("TextFormat");
    if("Y".equalsIgnoreCase(s1))
    adictionarydata[k1] = new DictionaryData("columnDataFormat", "textFormat");
    else
    adictionarydata[k1] = new DictionaryData("columnDataFormat", "numberFormat");
    catch(Exception exception1)
    adictionarydata[k1] = new DictionaryData("columnDataFormat", "numberFormat");
    tablebean.setColumnFormats(new ArrayDataSet(adictionarydata));
    return tablebean;
    private static OAWebBean createColumn(int i)
    OAFlowLayoutBean oaflowlayoutbean = new OAFlowLayoutBean();
    OAMessageTextInputBean oamessagetextinputbean = new OAMessageTextInputBean();
    OAMessageStyledTextBean oamessagestyledtextbean = new OAMessageStyledTextBean();
    OAMessageDateFieldBean oamessagedatefieldbean = new OAMessageDateFieldBean();
    OASwitcherBean oaswitcherbean = new OASwitcherBean();
    Hashtable hashtable = new Hashtable();
    hashtable.put("CtPPRTrgCol", new DataBoundValue(new CrossTableColumnData(i, "Name")));
    oaswitcherbean.setNamedChild("input", oamessagetextinputbean);
    oaswitcherbean.setNamedChild("date", oamessagedatefieldbean);
    oaswitcherbean.setChildNameBinding(new CrossTableColumnData(i, "Render"));
    oaflowlayoutbean.addIndexedChild(oaswitcherbean);
    oaflowlayoutbean.addIndexedChild(oamessagestyledtextbean);
    oamessagetextinputbean.setNameBinding(new CrossTableColumnData(i, "Name"));
    oamessagetextinputbean.setTextBinding(new CrossTableColumnData(i, "Text1"));
    oamessagetextinputbean.setAttributeValue(DESCRIPTION, new DataBoundValue(new CrossTableColumnData(i, "Label")));
    oamessagetextinputbean.setAttributeValue(COLUMNS_ATTR, "12");
    oamessagetextinputbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, OAWebBeanUtils.getFirePartialActionForSubmit(oamessagetextinputbean, null, "update", hashtable, null));
    oamessagetextinputbean.setDataType("NUMBER");
    oamessagetextinputbean.setAttributeValue(READ_ONLY_ATTR, new DataBoundValue(new CrossTableColumnData(i, "ReadOnly")));
    oamessagetextinputbean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, new DataBoundValue(new CrossTableColumnData(i, "SubmitValidator")));
    oamessagedatefieldbean.setNameBinding(new CrossTableColumnData(i, "Name"));
    oamessagedatefieldbean.setTextBinding(new CrossTableColumnData(i, "Text1"));
    oamessagedatefieldbean.setValueBinding(new CrossTableColumnData(i, "Text1"));
    oamessagedatefieldbean.setAttributeValue(DESCRIPTION, new DataBoundValue(new CrossTableColumnData(i, "Label")));
    oamessagedatefieldbean.setAttributeValue(COLUMNS_ATTR, "12");
    oamessagedatefieldbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, OAWebBeanUtils.getFirePartialActionForSubmit(oamessagedatefieldbean, null, "update", hashtable, null));
    oamessagedatefieldbean.setDataType("DATE");
    oamessagedatefieldbean.setAttributeValue(READ_ONLY_ATTR, new DataBoundValue(new CrossTableColumnData(i, "ReadOnly")));
    oamessagestyledtextbean.setTextBinding(new CrossTableColumnData(i, "Text2"));
    return oaflowlayoutbean;
    Pls let me know for any clarifications.
    Thanks,
    Srikanth

Maybe you are looking for

  • Apple TV recent software update- Magnification?

    If anyone from Apple Corp is listening, there is still a feature missing that I would like to see in a software upgrade to Apple TV. When I click on, "Top Movies" and I get a grid list of all the "Top Rentals" I would like for the highlighted movies

  • How do I suggest an accessory for the 2nd gen nano?

    I'm trying to make a suggestion to Apple to make a belt clip for the 2nd gen nano like the older 40gb iPods had. How do I make one, because I can't find any sort of suggestion box(for lack of better term)

  • Can i buy apple care on my 8th month of owning!

    i am readin about alot of things happening to macs , can i purchase apple care after i have already purchased my macbook which is 8 months old! or is it too late!

  • New retina iPad displaying Chinese characters

    My out of the box retina display iPad is showing Chinese characters even though I set the language to English under International in Settings.  How do I fix this?

  • RedHat PAK and license for UCS C220M3

    Dear Support Commmunity, I just got this new Cisco UCS C220-M3S where I should install a Cisco MATE and it requieres Redhat Enterprise Server 6.5. I also got the Cisco PAK for RedHat. I registered in the RedHat customer Portal, but I have not option