JSF programmatically add component

Hi, I'm using JDeveloper 10.1.3.3 on a Windows XP SP2 machine and java 1.5.0_06
I need to create component's programmatically for a page right now I have this code
patito.jsp (jsp page)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
  <html>
    <head>
      <meta http-equiv="Content-Type"
            content="text/html; charset=windows-1252"/>
      <title>patito</title>
      <style type="text/css">
      body {
      background-color: #f7f7f7;
    </style>
    </head>
    <body><h:form binding="#{backing_patito.form1}" id="form1">
        <h:outputText value="Hola mundo" binding="#{backing_patito.outputText1}"
                      id="outputText1"/>
        <h:inputText binding="#{backing_patito.inputText1}" id="inputText1"/>
        <h:commandButton value="commandButton1"
                         binding="#{backing_patito.commandButton1}"
                         id="commandButton1"
                         action="#{backing_patito.commandButton1_action}"
                         actionListener="#{backing_patito.commandButton1_actionListener}"/>
      </h:form></body>
  </html>
</f:view>Patito.java (The backing bean)
package prueba.view.backing;
import java.io.IOException;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import oracle.adf.view.faces.component.UIXInput;
public class Patito {
    private HtmlForm form1;
    private HtmlOutputText outputText1;
    private HtmlInputText inputText1;
    private HtmlCommandButton commandButton1;
    public Patito() throws IOException {
        HtmlForm form = (HtmlForm)FacesContext.getCurrentInstance().getViewRoot().findComponent("form1");
        if (form!=null){
            System.out.println ("Se ha hallado form1 ");
            //creo un nuevo output para agregarlo a el form recien hallado
            UIXInput input = new UIXInput();
            //HtmlInputText input = new HtmlInputText();
            input.setValue("hola");
            input.setId("patitoPerez");
            //input.setDisabled(false);
            input.setRendererType("javax.faces.Text");
            input.setRendered(true);
            if (FacesContext.getCurrentInstance().getViewRoot().findComponent("form1:patitoPerez") == null)
                System.out.println ("se ha agregado el input generado");
                form.getChildren().add(input);
        } else {
            System.out.println ("No se ha hallado form 1");
    public void setForm1(HtmlForm form1) {
        this.form1 = form1;
    public HtmlForm getForm1() {
        return form1;
    public void setOutputText1(HtmlOutputText outputText1) {
        this.outputText1 = outputText1;
    public HtmlOutputText getOutputText1() {
        return outputText1;
..........(more code)....
}If I run the page twice without checking if the component existe before adding it, it says that it have found the component duplicated in the view.
"javax.servlet.jsp.JspException: Id. de componente duplicado 'form1:patitoPerez' hallado en la vista."
so the code is working but it is not rendering the input text in the page.
any ideas?
Alain Reyes

My bad.
I didn't explain the reason for this aproach.
The thing is that I want to do a single page that handle de CRUD for a set of tables, but the number of fields of the table isn't constant, so I need to add the fields programmatically to make the screen just for the table.
I've resolved the issue, maybe it's a bug, the thing is that the code only function if the page it's a .jsfx.
Greetings.
Thanks for the reply.
Alain Reyes.

Similar Messages

  • Jsf data table component + print null cell

    I am using the jsf data table component and binding the column values to a backing bean.
    <h:dataTable binding="#{backing_showDifferences.dataTable2}"
    id="dataTable2">
    <h:column binding="#{backing_showDifferences.userColumn1}"/>
    <h:column binding="#{backing_showDifferences.userColumn2}"/>
    <h:column binding="#{backing_showDifferences.userColumn3}"/>
    </h:dataTable>
    - some code from my showDifferences.java
    HtmlOutputText column1Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.uclass}");
    column1Text.setValueBinding("value", vb);
    usercolumn1.getChildren().add(column1Text);
    HtmlOutputText column2Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.ue1}");
    column2Text.setValueBinding("value", vb);
    usercolumn2.getChildren().add(column2Text);
    HtmlOutputText column3Text = new HtmlOutputText();
    vb =
    FacesContext.getCurrentInstance().getApplication().createValueBinding("#{users.ue2}");
    column3Text.setValueBinding("value", vb);
    usercolumn3.getChildren().add(column3Text);
    ResultSetDataModel dataModel = new ResultSetDataModel();
    dataModel.setWrappedData(rs);
    dataTable2.setValue(dataModel);
    The raw HTML:
    <table id="form1:dataTable2" class="iuptable" border="1">
    <thead>
    <tr>
    <th scope="col">Heading 1</th>
    <th scope="col">Heading 2</th>
    <th scope="col">Heading3</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>some data in this column</td>
    <td>X</td>
    <td></td>
    </tr>
    <tr>
    <td>Some more data in this row</td>
    <td>X</td>
    <td></td>
    </tr>
    </tbody>
    </table>
    My problem is this...in the raw HTML the <td></td> tag is not formatted nicely on my table output. I have lines around my entire table and each cell within it. When the <td></td> prints there are no lines. I am new to the JSF table data component, but if I were writing some JSP or servlet code I would check that if value was null I would append an &nbsp to the <td> tag (ex. <td>&nbsp</td>) and the table would be formatted properly. The backing bean that I am binding to is pulling the data from a database table...so my sql looks like this:
    SELECT uclass, ue1, ue2 from table1; my problem is when ue1 or ue2 is a null value.
    Any ideas would be greatly appreciated!

    Hi,
    the h:dataTable belongs to the JSF Reference Implementation from Sun, not to Oracle ADF Faces. The rendering is within this component set and I suggest to report your issue on one of the SUN forums (http://forum.java.sun.com/forum.jspa?forumID=427) as we have no handle to e.g. fix an issue if it exists in the component set.
    Frank

  • Very Simple: How do I programmatically add line breaks?

    Very Simple: How do I programmatically add line breaks or how do I encapsulate my RichCommandLink's within a paragraph?
    My Code is as follows:
    for (String token : userViews.getViewNames())
    // add command link
    RichCommandLink output = new RichCommandLink();
    output.setText(token);
    // set action here
    // output.setActionExpression());
    viewItem.getChildren().add(output);
    // update view
    this.menuAccordion.getChildren().clear();
    this.menuAccordion.getChildren().add(0, viewItem);
    AdfFacesContext.getCurrentInstance().addPartialTarget(getMenuAccordion());

    Sorry, I'm using Jdeveloper 11.
    Im using JSP, JSF, ADF, Fusion. The RichCommandLink is an ADF Control.
    My PanelAccordion is bound to a RichPanelAccordion in my java class. When I add RichCommandLink's to the accordion the items are added next to each other. How do I add line breaks from my java class?

  • How to programmatically add rectangle to a pdf file ?

    How to programmatically add rectangle to a pdf file ?
    There is several page pdfs, non-vector, black and white.
    Users are color blind and have disabilities.
    To train them, one adds a rectangle at a certain lower-left point and width,height specified for a page.
    The idea is to give the script the page and coordinates and size of rectangle to be added programmatically. Green rectangles are acceptable as the cones are most sensitive there.
    Also, additional feature to add bookmarks on the left in the order these rectangle data is provided to the script.
    The script could be "hard-wired" by a list of the rectangle coodinates, and page number, pasted inside acrobat and run or entered into acrobat in some way.
    Your script would help many disabled people who are distributed through out the world.
    Feel free to contact me by email if you wish.
    Dying Vets

    P.S.
    This rectangle does not have to be a full annotation rectangle which needs user,date and a lot of info.
    Something minimal like this would suffice
    1 0 0 RG % red for stroke color
    200 300 50 75 re
    As you can see that the native unit of the pdf file is the "point" having 72 in an inch.
    The file dpi would be given. However, one could assume that pixel for the rectangle lower-left and width/height are given.
    From the pixels and dpi, the points could be calculated if desired.

  • Add component in task list

    Hello All,
    I have an issue with adding component in task list (for example task list number EIMN-68) via transaction IA05.
    When I try to add component to operation, I get the message *
    Standard BOM PAEIMN-68  4 already exists
    Message no. 29771
    Diagnosis
    You want to create a standard BOM for standard object PAEIMN-68 with usage .
    A BOM already exists for this standard object and usage. You cannot extend a standard a standard BOM.
    Procedure
    Check whether the standard BOM is suitable for standard object PAEIMN-68 and usage . If it is not, you need to create the BOM for another standard object.
    Is there any special way to create material master for such components.Whats the solution.
    Please help
    Cheers
    Sunny

    Hi Pithan, how are you..
    I want to add components.
    Just now I was able to add components. I explain how:
    When i added component number in operation, and press enter, system gave me the error that standard bom already exist. In the same screen I changed the BOM usage to 3 as universal usage. After this usage only, system allowed me to add components. No other bom usage allowed me to do so.
    Also, why system took me to BOM screen if I just want to add components.
    I wait for your reply.
    thanks and regards
    Sunny

  • Facing problem to add component in a panel dynamically

    I face serious problem to add component dynamically on a jpanel. can any one help me?
    I have one panel inside a frame. And I have another 3 or 4 panel. dynamically i want to change the panel inside the frame with the other panel.
    can anybody help me with source code?
    Your earliest response is highly appreciated.

    remove is reflected immediately without calling
    validate() but it does not work for adding. please
    give me some code.Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and http://www.yoda.arachsys.com/java/newsgroups.html

  • How to programmatically add UDVs to project?

    Hi all,
    I have successfully used something like this to programatically add shared variables to an LVLIB (the code assumes that the library associated with the Container Reference contains at least one variable):
    An example output would be:
    Container Name: "MyLibrary.lvlib"
    Variable Name: "Variable1"
    Variable Path: <blank>
    Variable Type String: "Variable"
    (I notice that there is no way to specify the data type of the variable, and LabVIEW creates a DBL variable in the LVLIB by default.)
    However, if Container Reference is associated with a "User-Defined Variables" container, then I get Error 1 at the Invoke Node ("LabVIEW: An input parameter is invalid"). A example output is:
    Container Name: "User-Defined Variables"
    Variable Name: "Variable1"
    Variable Path: <blank>
    Variable Type String: "Variable"
    Questions:
    Does the error occur because LabVIEW is trying to create a DBL variable (which is not allowed with UDVs)?
    How can I programmatically add UDVs to my project?
    Thanks in advance!

    What is the scope of your project? How will you be using these UDV's?
    Mark P.
    Applications Engineer
    National Instruments
    www.ni.com/support

  • Dynamic add component to panel, it does't work

    I want to add a label in a panel when you click button.
    I used revalidate() and revalidate() method, but it didn't appear in panel.
    HELP ME?? WHAT'S WRONG!
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    jPanel1.add(new JLabel("Hello"));
    jPanel1.revalidate();
    jPanel1.repaint();
    }

    i add Layout manager to panel. It works. Thanks,
    So tricky things for dynamic adding component:
    1, setup layout manager to container (such as panel),
    2, add component to container
    3, call revalidate() method to relayout these components in container
    You can't miss any one of those.
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    jPanel1.setLayout(new FlowLayout());
    jPanel1.add(new JButton("Hello"));
    jPanel1.revalidate();
    }

  • How can i programmatically add a text in a combobox drop down menu ?

    How can i programmatically add a text in a combobox drop down menu ? Can it be possible using any property node?

    You've posted to the wrong forum. Please post to the LabVIEW board.

  • Able to add component in approved Purchase Req from PM

    Hello,
    I have scenario where I create Purchase requisition from Plant Maintenance Work order and I have collective functionality turn on, means if I add component in the work order it will be added in the Purchase requisition created against that work order. now my requirement is if my purchase requisition is approved system should not allow me to add the component to same purchase requisition from PM work order.
    any help would be highly appreciated.
    Regards
    Shailendra

    Dear shailendra soni,
    Have you tried Changeability of Purchasing Document During/After Release.
    Path is :SPRO->MM->Purchasing->PR-Rel.Str.Procedure W/Classification->Setup Procedure with Classification-Release indicator
    Here as per your release code - select required option which suits you - (1- cannot be changed)
    Refer Image
    reg,
    Bhg

  • Render Related -JSF Third party Component

    Hai All
    I am having doubt regarding JSF Third party component like Jmaki ,MyFaces or something like that . How the third party component match with JSF life cycle even though there is no java classes for managing and rendering the Third party component . what i basically mean to say is if we use <h:inputText> in our JSF page , the inputText component will managed by many java class like UIInput.class and HtmlInputText and InputTextRender and so on. next if we use dojo.dropdowndatepicker ,there is component for managing this component like UIDate, HtmlData .
    could you tell me how third party component working without any problem.
    Thanks for advance
    Selvakumar.k

    If you look in the jar files for the libraries, you will find a faces-config.xml file containing such configurations.

  • How to programmatically add af:setPropertyListener to CommandImageLink

    Hi All,
    My Requirement: programmatically add af:setPropertyListener to CommandButton
    I referred this post how to programmatically add af:setPropertyListener to CommandButton and followed the following code.
    Code:
    // create a value expression
    ValueExpression vx =
    elFactory.createValueExpression(elContext, "#{pageFlowScope.clockNo}",
    String.class);
    // set a default value if desired
    vx.setValue(elContext, clockNo);
    SetPropertyListener spl =
    new SetPropertyListener(ActionEvent.class.getName());
    spl.setFrom(clockNo);
    spl.setValueExpression("to", vx);
    // add the listener to the button
    newOpButton.addActionListener(spl);
    My Code:
    <af:commandImageLink id="editInsuraceDetLink"
    icon="/resources/images/Edit.jpg"
    iconPosition="trailing"
    rendered="#{not row.deleted}"
    action="addEndorsement"
    useWindow="true"
    inlineStyle="vertical-align:bottom;"
    partialSubmit="true"
    shortDesc="Edit"
    *actionListener="#{pageFlowScope.GetEndorsementTypeListener.execute}"*
    returnListener="#{GetEndorsementDetailsListener.execute}"
    windowEmbedStyle="window"
    windowModalityType="applicationModal"
    windowHeight="650" windowWidth="740">
    </af:commandImageLink>
    Action Listener - .GetEndorsementTypeListener.execute code:
    RichCommandImageLink a_button = (RichCommandImageLink) a_component.findComponent("editInsuraceDetLink");
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application application = fctx.getApplication();
    ELContext elContext = fctx.getELContext();
    ExpressionFactory elFactory = application.getExpressionFactory();
    ValueExpression vx = elFactory.createValueExpression(elContext, "#{pageFlowScope.controlFlowName}", String.class);
    // set a default value if desired
    //vx.setValue(elContext, clockNo);
    SetPropertyListener spl = new SetPropertyListener(ActionEvent.class.getName());
    spl.setFrom(a_target.getEndorsementFor().toString());
    spl.setValueExpression("to", vx);
    System.out.println("From= "+spl.getFrom());
    System.out.println("To= "+spl.getValueExpression("to"));
    // add the listener to the button
    a_button.addActionListener(spl);
    I got the following output.
    From= Nominee / Appointee
    To= ValueExpression[#{pageFlowScope.controlFlowName}]
    Now my Problem is: the pageFlowScope variable ControlFlowName is not set.
    And also I got a *link*: https://blogs.oracle.com/vijaymohan/entry/usage_of_setpropertylistener_and_setactionlistener
    Whats wrong with my code. Is my problem related with above *link*.
    Please suggest me how to add SetPropertyListener programmatically.
    -Thanks
    Mohanraj

    Frank,
    This works:
            // create a value expression
            ValueExpression vx =
                elFactory.createValueExpression(elContext, "#{pageFlowScope.clockNo}",
                                                String.class);
            // set a default value if desired
            vx.setValue(elContext, clockNo);
            SetPropertyListener spl =
                new SetPropertyListener(ActionEvent.class.getName());
            spl.setFrom(clockNo);
            spl.setValueExpression("to", vx);
            // add the listener to the button
            newOpButton.addActionListener(spl);But, I am thinking you would have known about it before I posted it. I don't really know how it works, but it does.
    Can you help me reconcile between this, and what you said. Because what you said makes sense too.

  • Programmatically add contacts

    I was wondering if there is a way to programmatically add contacts, and possibly search for duplicates.

    "contacts"? Not sure what context you're talking about ... What are "contacts"?

  • Programmatically add front panel objects

    hello,
    I would like to programmatically add controls and indicators to a front panel. I have read a thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=70347&query.id=10819#M70347
    Ben Rayner describes a technique which takes an image of the relavant object, then adds this image to a picture on the front panel. I was wondering if anyone has an example of this techinique? Or if there is a simpler method of doing it?
    Thanks,
    paul.

    Hi Paul,
    This thread contains a collection of Picture related threads.
    Contained in that collection you will find a link to this thread where in reply #52 I posted an entry for the "Obfuse Code Challenge" . In that example I grab the image of a boolean and use it in a Picture control to play a game of Hang Man" while executing a random walk to speel out "Hello World". That code is not documented since the game was to be obfuse.
    In reply #33 of this thread, I posted a new version of the CC and Friends" project where I used a picture control to display an arbitrary set of images.
    Ading to the above:
    I have developed and delivered "Controls on the Fly" applications
    add they were well recieved, BUT....
    They are not trivial!
    So if you would like to share what you are trying to accomplish, we may be able to makes suggestions that are esier to implement. 
    Ben
    * Art work by Christian Altenbach
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Programmatically add meta tags to docs

    Is there a way to programmatically add custom meta tags to
    documents that are being uploaded via CF? I am looking to do this
    for our Google Mini Search Appliance.
    Thanks,
    Josh

    You couldn't find the answer by searching?!? Why be concerned with searching if you do not search yourself?
    c'mon

Maybe you are looking for

  • Bug Datepicker icon position in RTL environment

    Hello everybody! My ApEx version is  4.2.3.00.08 on Oracle 11g R2 Windows 64 bit platform. My application is Right To Left oriented (language is Hebrew) - it's working application which has been RTL adjusted. When using new Date picker (j Query) I ge

  • Diaplay  Word file stored in blob into a browser using JSP

    Dear All I have files stored in oracle table in a blob field.I store the files using forms 10g and webutil. I can upload the files and display them successfully in forms, however when i use JSP to retrieve the files and display them in Internet Explo

  • InDesign CS5 won't launch on Mac OS 10.8.3

    InDesign CS5 won't launch on Mac OS 10.8.3

  • How to see / limit consecutive login failures?

    Hi, our server is running 10.4.7 server. In terms of hardening the machine against attacks, is there be default a limit to the number of failed logins that occur before an account is locked in some way? If not, is there a way to turn ON that security

  • Set waveform chart size to value 1000

    Is there any possibility to set the size of waveform chart buffer to value >1000 in LabVIEW? Message Edited by Konigusko on 05-03-2006 09:40 AM