HtmlCommandLink in Dynamic datatable

Hi All,
I got the dynamic data table working with help from http://balusc.xs4all.nl/srv/dev-jep-dat.html
I want to have a command link for all the cells . I tried the following code. It shows the link. But when I click on the link it just refreshes the same page !!!
HtmlCommandLink column1Text = new HtmlCommandLink();
ValueBinding vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{contact.createSetup}");
column1Text.setValueBinding("action", vb);
ValueBinding vbvalue =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{myItem[" + i + "]}");
column1Text.setValueBinding("value", vbvalue);
UIParameter param = new UIParameter();
param.setName("parm1");
param.setValue("test");
column1Text.getChildren().add(param);
// Set column.
UIColumn column = new UIColumn();
column.setHeader(header);
column.getChildren().add(column1Text);
// Add column.
dynamicTable.getChildren().add(column);
Any idea what I am doing wrong?? Any help is appreciated much..
regards
Reghu

Hello BalusC,
i am not sure if I have understand your tip how to fix it.
I want to build a menu, too.
linktext = new HtmlOutputText();               
linktext.setValue("WorkBench");
MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("workbench", null);
HtmlCommandLink cmdlink = new HtmlCommandLink();
cmdlink.setAction(mb);
cmdlink.setImmediate(true);
cmdlink.setId("MainMenuWorkbenchLink");                         
cmdlink.getChildren().add(linktext);
this.menu.getChildren().add(cmdlink);But I get an javax.faces.el.ReferenceSyntaxException: workbench when I try to set up the mb.
any idea why?
Greets and Thanks

Similar Messages

  • To find the "column value"  when clicked on Dynamic datatable

    I ahve done a dynamic table where the first row alone i ahve declared as command link.So when I click on the commadn link I need to get either column name or column count or rowdata.If I Get then I have some logic based on it to do.
    I have placed my dynamic datatable code below.
    public class Datatable2 extends PageCodeBase
    UIData dataTable =new UIData();
    public Datatable2()
    UIColumn col;
    UIOutput out = null;
    ArrayList al=new ArrayList();
    al.add("Item");
    al.add("Creation date");
    al.add("Priority");
    Application app = FacesContext.getCurrentInstance().getApplication();
    int colCount = 3;
    for(int j = 0; j < colCount; ++j) {
    out = new UIOutput();
    col = new UIColumn();
    if(dataTable.getRowIndex()==-1)
    MethodBinding mb = app.createMethodBinding("#{pc_DataTable.item}", null);
    HtmlCommandLink link = (HtmlCommandLink)app.createComponent(HtmlCommandLink.COMPONENT_TYPE);                     link.setActionListener(mb);
    link.setAction(mb);
    link.setId("Command"+j);
    ValueBinding vb1 = app.createValueBinding("#{commands" + j + "}");
    link.setValueBinding("value",vb1);
    link.setRendererType("javax.faces.Link");
    HtmlOutputText O = new HtmlOutputText();
    O.setValue(al.get(j).toString());
    link.getChildren().add(O);
    col.setHeader(link);   
    ValueBinding vb = app.createValueBinding("#{rows["+j+"]}");
    out.setValueBinding("value", vb);
    out.setRendererType("javax.faces.Text");
    col.getChildren().add(out);
    dataTable.getChildren().add(col);
    public UIData getDataTable()
         return dataTable;
    public void setDataTable(UIData dataTable)
    this.dataTable=dataTable;
    public Object[] getTableRows()
    Object[] test = new Object[]{new String[]{"1","2","3"},
    new String[]{"4","5","6"},
    new String[]{"7","8","9"},
    new String[]{"10","11","12"},
    new String[]{"13","14","15"}};
    return test;
    this is my jsp code
    <f:view>
    <P>Place content here.</P>
    <h:form>
    <h:dataTable binding="#{pc_Datatable2.dataTable}" value="#{pc_Datatable2.tableRows}" var= "rows" />
    </h:form>
    </f:view>
    Could please tell how can i figure out my coulmn value when clicked on the command link

    hello,
    u can use two types methods  u can create a dynamic action or by branching using conditional or java script code
    for java script code just call the code when button clicked and in javascript function by using if condition u can redirect.
    Regards,
    Ramana

  • How to create dynamic DataTable with dynamic header/column in JSF?

    Hello everyone,
    I am having problem of programmatically create multiple DataTables which have different number of column? In my JSF page, I should implement a navigation table and a data table. The navigation table displays the links of all tables in the database so that the data table will load the data when the user click any link in navigation table. I have gone through [BalusC's post|http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDynamicDatatable] and I found that the section "populate dynamic datatable" does show me some hints. In his code,
    // Iterate over columns.
            for (int i = 0; i < dynamicList.get(0).size(); i++) {
                // Create <h:column>.
                HtmlColumn column = new HtmlColumn();
                dynamicDataTable.getChildren().add(column);
                // Create <h:outputText value="dynamicHeaders"> for <f:facet name="header"> of column.
    HtmlOutputText header = new HtmlOutputText();
    header.setValue(dynamicHeaders[i]);
    column.setHeader(header);
    // Create <h:outputText value="#{dynamicItem[" + i + "]}"> for the body of column.
    HtmlOutputText output = new HtmlOutputText();
    output.setValueExpression("value",
    createValueExpression("#{dynamicItem[" + i + "]}", String.class));
    column.getChildren().add(output);
    public HtmlPanelGroup getDynamicDataTableGroup() {
    // This will be called once in the first RESTORE VIEW phase.
    if (dynamicDataTableGroup == null) {
    loadDynamicList(); // Preload dynamic list.
    populateDynamicDataTable(); // Populate editable datatable.
    return dynamicDataTableGroup;
    I suppose the Getter method is only called once when the JSF page is loaded for the first time. By calling this Getter, columns are dynamically added to the table. However in my particular case, the dynamic list is not known until the user choose to view a table. That means I can not call loadDynamicList() in the Getter method. Subsequently, I can not execute the for loop in method "populateDynamicDataTable()".
    So, how can I implement a real dynamic datatable with dynamic columns, or in other words, a dynamic table that can load data from different data tables (different number of columns) in the database at run-time?
    Many thanks for any help in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    flyeminent wrote:
    However in my particular case, the dynamic list is not known until the user choose to view a table. Then move the call from the getter to the bean's action method.

  • Generating a REAL dynamic datatable

    Hi,
    I've been looking for a solution, reading a lot of books about server faces, understood the whole Beans concept, took some sun courses (incl 314) but still don't get one thing. I need to finish a project and i have to move on fast now.
    I want to be able to :
    Generate a dynamic datatable from any query, WITHOUT having to know and create each column component for each resulting column.
    In addition i need to be able to have a commandbutton on each row, that would enable me to retrieve which row should be updated exactly.
    I found tons of examples on that, some people on forums wrote about how to do dynamic datatables, but they created each column from start and binded them to a fix field. I read a lot and tried a lot and til now i was just dissappointed of some people's code spaming google search results on "dynamic datatable" that definetly is not a dynamic datatable.
    I tried myfaces samples too from apache, decompiled their bean, but they backing it with a simple datamodel and an arraylist :-(
    1. I need someone to explain me how to generate a dynamic datatable.
    2. I need to back that datatable with a cachedRowSet or a ResultSet and to understand how to get UIData from a ResultSet.
    Sincerely please help i really need help about that fast.

    The goal i wanted to reach (and my definition of "dynamic") is not having to redesign everything as soon as something changes.
    Because binding has to be done, objects have to be declared for each column, and because binding is not dynamic (no expression), you cannot have a REAL dynamic datatable. I got that now meanwhile.
    Exactly as i thaught (still HTML cough), it's web-based and a problem of the programming language.
    Like in Delphi Pascal, or any none web-based development language, one could have done such thing in 5 minutes.
    The problem with Java JSP JSF is that you only find out its limits after you have put some time into it, but not when you get conviced to use it.
    I remember speaches swearing "it can do everything that other languages can and more ..." Well, i don't think so.
    I meanwhile found so many threads of programmers, having to migrate to Java JSP JSF and now being lost in the same situation.
    Still open to any suggestions.

  • Dynamic datatable:adding rows

    I am working with Dynamic datatable . whilke adding a row i am able to add only one row . later i am unable to a dd .
    code:
    <h:commandLink value="ADD" action="#{icdMBean.actionAddrow}" />
    back bean:
    public void actionAddrow() {
    // Create new items.
    icdList= new ArrayList<Icd>();
    Icd myNewDataItem = new Icd();System.out.println("i am in action add row2");
    myNewDataItem.setId("new");
    icdList.add(myNewDataItem);
    if i set the id value( myNewDataItem.setId("new");) only i am able to add only one row .
    could you please suggest a solution for it.

    Hi, many thanks for your answer, so what do you think is the best solution for adding rows by user to interactive form's dynamic table?
    Manually read xml data during submit by this way: https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9121. [original link is broken] [original link is broken] [original link is broken] ?
    Or is there better solution for this? (any link to some examples, blogs, etc...)
    Many thanks for any answer!

  • How to create a Dynamic Datatable with sorting functioanlity

    Hi,
    I am new to JSF and need some help can some one please tell me how to create a dynamic datatable with sorting functionality. I am reading data data from a database table and wants to build the datatable dynamically based on the columns returned. I know how to created a datatble with a fixed number of columns but can't figure out how to create a datatable dynamically with sort functionality. Any small example will help.
    Thanks

    Hi,
    Here is what I have so far and can't figure out how to add the sorting functionality. Any help is appreciated.
    Managed Bean:
    private List<MyDto> data ;
        public HtmlDataTable getDataTableOne ()
            if ( dataTableOne == null )
                populateCheckBoxes () ; // Preload.
                populateDynamicDataTableOne () ;
            return dataTableOne ;
        public void populateCheckBoxes ()
            data = new ArrayList<MyDto> () ;
            MyDto myDto1 = new MyDto () ;
            MyDto myDto2 = new MyDto () ;
            MyDto myDto3 = new MyDto () ;
            MyDto myDto4 = new MyDto () ;
            myDto1.setChecked ( true ) ;
            myDto1.setValue ( "myDto1" ) ;
            myDto2.setChecked ( false ) ;
            myDto2.setValue ( "myDto2" ) ;
            myDto3.setChecked ( false ) ;
            myDto3.setValue ( "myDto3" ) ;
            myDto4.setChecked ( true ) ;
            myDto4.setValue ( "myDto4" ) ;
            data.add ( myDto1 ) ;
            data.add ( myDto2 ) ;
            data.add ( myDto3 ) ;
            data.add ( myDto4 ) ;
        public void populateDynamicDataTableOne ()
            dataTableOne = new HtmlDataTable () ;
            UIOutput header = new UIOutput () ;
            header.setValue ( "" ) ;
            UIColumn tableColumn ;
            tableColumn = new UIColumn () ;
            HtmlOutputText textHeader = new HtmlOutputText () ;
            textHeader.setValue ( "" ) ;
            tableColumn.setHeader ( textHeader ) ;
            HtmlSelectBooleanCheckbox tCheckBox = new HtmlSelectBooleanCheckbox () ;
            tCheckBox.setValueBinding ( "value" , FacesContext.getCurrentInstance ().getApplication ().createValueBinding ( "#{row.checked}" ) ) ;
            tableColumn.getChildren ().add ( tCheckBox ) ;
            // Set output.
            UIOutput output = new UIOutput () ;
            ValueBinding myItem = FacesContext.getCurrentInstance ().getApplication ().createValueBinding ( "#{row.value}" ) ;
            output.setValueBinding ( "value" , myItem ) ;
            // Set header (optional).
            UIOutput header2 = new UIOutput () ;
            header2.setValue ( "" ) ;
            UIColumn column = new UIColumn () ;
            column.setHeader ( header2 ) ;
            column.getChildren ().add ( output ) ;
            dataTableOne.getChildren ().add ( tableColumn ) ;
            dataTableOne.getChildren ().add ( column ) ;
    MyDto.java
    public class MyDto
        private Boolean checked;
        private String value;
        public MyDto ()
        public void setChecked ( Boolean checked )
            this.checked = checked;
        public Boolean getChecked ()
            return checked ;
        public void setValue ( String value )
            this.value = value;
        public String getValue ()
            return value ;
    JSP
    <h:dataTable id="table" value="#{myRequestBean.data}" binding="#{myRequestBean.dataTableOne}" var="row" />Thanks

  • Creating dynamic dataTables **Very Urgent**

    Hi all,
    I m very new to JSF Technology. I m in need of creating dynamic dataTables. I need to populate the values from DB. At times, the number of columns varies. So, how can i create such kind of table? At least i need to know how can i create dataTable values using the Backing bean and mapping it to the JSF page, so that the browser will render that dataTable?
    Please help me.. :)

    The following code (taken from the BalusC article) do the task:
                // Create <h:column>.
                HtmlColumn column = new HtmlColumn();
                dynamicDataTable.getChildren().add(column);
                // Create <h:outputText value="dynamicHeaders"> for <f:facet name="header"> of column.
    HtmlOutputText header = new HtmlOutputText();
    header.setValue(dynamicHeaders[i]);
    column.setHeader(header);
    // Create <h:outputText value="#{dynamicItem[" + i + "]}"> for the body of column.
    HtmlOutputText output = new HtmlOutputText();
    output.setValueExpression("value",
    createValueExpression("#{dynamicItem[" + i + "]}", String.class));
    column.getChildren().add(output);

  • Formatting a dynamic datatable

    Hello, I am displaying a datatable on screen with a dynamic number of columns and rows and everything is working fine. However, I would also like to apply columnClass formatting to the columns and obviously the number of classes is dependent on the number of columns. In a regular static datatable in our system, I would normally do something like:
    columnClasses="tierNameStyle,tierCheckStyle,tierNameStyle,tierNameStyle" styleClass="dataTableStyle"But if I add this into my dynamic datatable JSP as this, it ignores the formatting:
    <h:dataTable binding = "#{dataSetBB.dataSetTableHeadings}" var="rows" value="#{dataSetBB.tableHeadingRows}" columnClasses="tierNameStyle,tierCheckStyle,tierNameStyle,tierNameStyle" styleClass="dataTableStyle"/>Is there a way to do this in the backing bean since I am doing everything else for the dynamic table there?

    OK, I tried that and it still seems to be ignoring my columnClasses. Here is my code from the backing bean where I am building the table. Am I doing something wrong?:
         public DataSetBB(){
                   //setup dataModel
                   String[] colHeadings = new String[]{"Heading1", "Heading2", "Heading3"};
                   String[] colDetail = new String[]{"Detail1", "Detail2", "Detail3"};
                   Object[] headingsArray = new Object[]{colHeadings};
                   Object[] detailArray = new Object[]{colDetail};
                   tableHeadingRows = new ArrayDataModel();
                   tableHeadingRows.setWrappedData(headingsArray);
                   tableDetailRows = new ArrayDataModel();
                   tableDetailRows.setWrappedData(detailArray);
                   //setupTable
                   dataSetTableHeadings = new HtmlDataTable();
                   dataSetTableDetails = new HtmlDataTable();
                   dataSetTableHeadings.setStyleClass("dataTableStyle");
                   dataSetTableHeadings.setColumnClasses("tierNameStyle,tierCheckStyle,tierNameStyle");
                   dataSetTableDetails.setStyleClass("dataTableStyle");
                   dataSetTableDetails.setColumnClasses("tierNameStyle,tierCheckStyle,tierNameStyle");
                   UIColumn col;
                   UIInput in = null;
                   Application app  = FacesContext.getCurrentInstance().getApplication();
                   int colCount = colHeadings.length;
                   for(int j = 0; j < colCount; ++j) {
                        in = new UIInput();
                        col = new UIColumn();
                        in.setId("input" + j);
                        ValueBinding vb = app.createValueBinding("#{rows["+j+"]}");
                        in.setValueBinding("value", vb);
                        in.setRendererType("javax.faces.Text");
                        col.getChildren().add(in);
                        dataSetTableHeadings.getChildren().add(col);
                   for(int j = 0; j < colCount; ++j) {
                        in = new UIInput();
                        col = new UIColumn();
                        in.setId("detail" + j);
                        ValueBinding vb = app.createValueBinding("#{rows["+j+"]}");
                        in.setValueBinding("value", vb);
                        in.setRendererType("javax.faces.Text");
                        col.getChildren().add(in);
                        dataSetTableDetails.getChildren().add(col);
         }

  • Dynamic datatable and command link

    I'm having a problem creating CommandLink's automatically. What we have is a tag, which can contain a set of data. We need this on several locations, so we have to create a datatable dynamically. When you press a link, it should be possible to retrieve the ID of the component on that specific row.
    The problem is, we can create the table with the necessary data. When I construct the column with the ID (and the link), it fails.
    Code:
    HtmlCommandLink link = new HtmlCommandLink();
    Application app = FacesContext.getCurrentInstance().getApplication();
    ELContext elContext = FacesContext.getCurrentInstance().getELContext();
    ValueExpression ve = app.getExpressionFactory().createValueExpression(elContext,"${" + TABLE_VAR_NAME + "." + property + "}", Object.class);
    link.setValueExpression("value", ve);
    link.getAttributes().put("rowId", ve.getExpressionString() );
    link.addActionListener(
        new ActionListener(){
         public void processAction(ActionEvent arg0)
              throws AbortProcessingException {
              LOG.info(">>>>>>>>>>>>> Linked pushed !!"  +
              arg0.getComponent().getAttributes().get("rowId"));
    selectColumn.getChildren().add(link);
    datatable.getChildren().add(selectColumn);The rowId is always #{row.code}, instead of the actual data. Is there a way to create a command link dynamically, press it and retrieve the ID of that field? That expression should be evaluated at runtime and added to the datatable, but that doesn't happen apparently.

    I've read your article, but I didn't find anything I could use. Facing a deadline and don't really have time to try out multiple (possible) solutions. The problem is that all the examples I can find point to MethodBinding, but I don't need that. I just need to get the ID of the row that was clicked, nothing more.
    This works fine:
    link.setValueExpression("value", ve);I don't see why the other expression isn't evaluated.
    I can do getParent().getParent() to get a reference to the DataTable, but the datamodel on that object is empty btw.

  • Dynamic DataTable without validation of the rest of the form

    I'm having a bit of trouble implementing a piece of functionality with JSF and I'm hoping someone here will have some insight into how to accomplish this.
    I have a quite large form, with some fields requiring quite complex and expensive (both performance and actual money) validation (e.g. calling external web services, etc.). For the sake of the explanation, let's say the user enters details about himself, such as name, social security number, address, etc. Along with his details, he's to enter a limited subset of the details for each of his children (say name and social security number). We do not know at design time how many children the user has (obviously), so this part of the form has to be dynamically generated. Validation is performed on these children fields as well, so the user needs to be able to edit and remove children from the form.
    Prior to JSF (straight JSP), I used DHTML and a naming scheme for these records with a custom setters in the backing beans.
    What I have tried with JSF is to have a DataTable backed by a List. This table contains a single "Add Child" button which adds a new empty row to the table. There is also a "Remove" button for each row.
    This works just great as long as I allow all other fields in the form to validate each time the user clicks the button. However, as I stated before, these validations are very very expensive (transaction based costs) . Additionally, I do not want to force the user to fill in all the other required fields (close to 40) before he can go on with the children.
    Now, setting immediate="true" on the commandButton elements solves the problem of the other form fields validating. However, now the Children in the DataTable are never set because the update model values phase is never invoked, leaving me with empty input fields. I really do not care in this instance whether the data for the Children is valid or not, I just need to get them into the form.
    I can think of at least three possible solutions:
    1) Split up the form into several pages, like a wizard. However, the customer has rejected this option.
    2) Somehow simplify the Children section by providing a single entry and a read-only table. This way I can use a simpler read-only table and I can extract the values from the request parameters directly. However, this complicated the editing of previously entered Children. To make things worse, the order of the children has to remain intact.
    3) Create a custom HtmlInputText component that sets the values regardless of whether immediate="true" or "false".
    It is this last option that I do not know how to do. Which methods would I need to override in order to get the values to be set in my bounded Children object regardless of the immediate flag?
    And of course, if anybody has any other design suggestions I'm open to them!
    Thanks in advance!
    /Kris

    nboudani , let me answer your question first. The page does have a Submit button. It also has "Add Child" and "Remove Child", and some others as well. The Submit button has immediate="false". I also need form validation for interdependent form fileds (e.g. either Passport number or social security number are required), so I'm using the "hidden input field at the bottom of the form trick". This all works well enough.
    OK, I got partway there. jaguar2010's mention of valueChangeListener made me investigate that further. So what I did was twofold. Set the immediate attribute to true for the inputText elements in question (for the Children data) as well as for the commandButton (as before). Also, add a valueChangeListener for each of the Children which simply calls updateModel.
    So, view code:
    <h:inputText id="cName"
                           valueChangeListener="#{testBean.procCNameValueChanged}"
                           value="#{child.name}"
                           required="true"
                           immediate="true"/>
    <h:inputText id="cSS"
                           valueChangeListener="#{testBean.processCSSValueChanged}"
                           value="#{child.ss}"
                           validator="#{testBean.validateCSS}"
                           immediate="true"/>
    <h:commandButton action="#{testBean.addChild}" immediate="true" value="Add Child"/>
    ...bean code:
    public void procCNameValueChanged(ValueChangeEvent event) {
        HtmlInputText sender = (HtmlInputText) event.getComponent();
        sender.updateModel(FacesContext.getCurrentInstance());
    }So, that does take care of the problem with the model not updating. However, there are a bunch of other problems still left to be resolved. For instance, as you'll notice, there is a validator attached to one of the inputs. If this validation fails, the invalid text is not put back in the input field. I can't temember now, but I think that is because the valueChangeListener is not called in that case, so the model is not updated. Sigh...
    Another problem is that for each row in the data model's table, there is a "Remove" button (not shown in above code) to enable the user to remove an entry from the list of children. Well, because JSF process events in the order of their appearance in the view code, an exeption is thrown if the removed row is not the last one, and the last row has not been "saved" yet. That is, the valueChangeListener has not been called on the last row. What happens is that first the action method for the remove button is called, then the valueChangeListener for the last row is called. But by the time the valueChangeListener event is fired, the last row has chaned its index (because the remove action method was called first) and apparently this fact has escaped JSF so it throws an exception (property not found or something).
    I'm starting to wonder if JSF is the wrong technology for complex forms. Just seems to want to do too much for me, assuming I have a simple form.

  • Dynamic datatable in custom component

    hi all,
    i'm working on a custom jsf component and this component will create a datatable dynamically. (you can see component details from http://www.jroller.com/page/hasant?entry=creating_dynamic_datatable_inside_of AND http://www.jroller.com/page/hasant?entry=jsf_question_for_community_what)
    the question is; when i want to add a selection column(dynamically), how can i handle its selected values?
    i mean, if i have created this datatable in a page with designer, i would bind an Integer[] to that selection column's checkboxes. But i have to add this selection column dynamically from my component. So, how can i GET and SET the selection columns values. Since this is a custom component, there is no backing bean for value binding to this component.
    when i resolve the request param string to get the selected rows, it's working(=i can see the selected rows somehow..) but, i can not set that values again while encoding that column after a submit.
    here is my row selection column encoding code;
         private void addSelectionColumnToTable(FacesContext context, UIData table) {
              UIColumn column = new UIColumn();
              HtmlInputRowSelect rowSelect = new HtmlInputRowSelect();
              rowSelect.setId("rowSelect1");
              rowSelect.setStyleClass("inputRowSelect");
              rowSelect.setValue(m_selectedRows);
              column.getChildren().add(rowSelect);
              table.getChildren().add(column);
         }In the code above, rowSelect.setValue(m_selectedRows); part not effecting anyhing. m_selectedRows variable includes row numbers(in an Integer array) that i want to see as selected.
    any solution/recommendation?

    Well if you are still interested in using a text component
    instead of a Button the way you would go about this is using
    textWidth. Here's how I've done it before using a text / label
    whatever you want that shows text.
    // => Set our text we got from database
    myText.text = "This is the text I got from the DB";
    // => Validate it so that way we make sure we get right
    numbers
    myText.validateNow();
    // => Find out how wide our text really is.
    var textWidth:Number = myText.textWidth
    // => Reset the width of our text component and add 20 for
    a little buffer
    myText.width = textWidth + 20;
    Now my suggestion is if your going to be dynamically creating
    these on the fly from a database call you throw it into a method /
    class and have that do all the work for you so all you have to do
    is pass the text to it and it resizes itself based on the example
    above.

  • Dynamic DataTable Creation

    Hi
    I want to write dataTable dynamic. with command link column..for that I had written following code.
    import javax.faces.application.Application;
    import javax.faces.component.UIInput;
    import javax.faces.component.UIMessage;
    import javax.faces.component.UIOutput;
    import javax.faces.component.UIColumn;
    import javax.faces.component.UIData;
    import javax.faces.component.UIPanel;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.component.html.HtmlDataTable;
    import java.util.ArrayList;
    import javax.faces.component.html.HtmlOutputLink;
    protected void populateDataTable() { //
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application application = facesContext.getApplication();
    UIData panel = (UIData) application.createComponent("javax.faces.component.html.HtmlDataTable");
    String valueBindingExpressionForPanel1 = "#{" + "ListHolderBean.employeeList" + "}";
    String valueBindingExpressionForPanel2 = "employee";
    ValueBinding valueBindingForPanel1 = application.createValueBinding(valueBindingExpressionForPanel1);     
    ValueBinding valueBindingForPanel2 = application.createValueBinding(valueBindingExpressionForPanel2);
    panel.setValueBinding("value", valueBindingForPanel1);
    panel.setValueBinding("var", valueBindingForPanel2);
    for (int index = 0; index < 2; index++) {
         UIColumn column = (UIColumn) application.createComponent("javax.faces.component.UIColumn");
         //output link     
    UIOutput outputLink = (UIOutput) application.createComponent("javax.faces.component.html.HtmlOutputLink");
    // message.getAttributes().put("for", fieldNames[index]);
    String valueBindingExpression = "#{" + "employee.name" + "}";
    ValueBinding valueBinding = application.createValueBinding(valueBindingExpression);     
    System.out.println(valueBindingExpression);
    outputLink.setValueBinding("title", valueBinding);
    outputLink.setValueBinding("value", valueBinding);
    ValueBinding valueBinding2 = application.createValueBinding("update(this.title);");
    outputLink.setValueBinding("onmousedown", valueBinding2);
    ValueBinding valueBinding3 = application.createValueBinding("onclick");
    outputLink.setValueBinding("onclick", valueBinding3);
    column.getChildren().add(outputLink);
    panel.getChildren().add(column);
    Following error comes when I run this code
    Named Object: 'javax.faces.component.html.HtmlDataTable' not found.
    What is issue although I had import that file also .

    Application#createComponent() requires ComponentType. For an HtmlDataTable it is "javax.faces.HtmlDataTable". Also see HtmlDataTable.COMPONENT_TYPE.
    So you have to use createComponent(HtmlDataTable.COMPONENT_TYPE);.
    Or just HtmlDataTable table = new HtmlDataTable();
    By the way an OutputLink is not the same as CommandLink.

  • Jsf dynamic datatable

    Hi
    How can we make the columns of a datatable dynamic, I mean without knowing the numbers columns of the list to present in the datatable?
    thanks for help

    Yep, just build the h:columns inside a repeat tag that gets evaluated at the right time, like c:foreach.

  • Generate dynamic DataTable for Values selected from SelectManyListBox

    I want to generate a datatable for values selected in a selectManyListBox,
    DataTable will have three columns
    1serial number
    2.values selected from listbox
    3.inputText for entering some data
    Plz guide me how can i do this...
    Thanx in advance!

    Check http://balusc.xs4all.nl/srv/dev-jep-dat.html how to use datatables.

  • Displaying tables with dynamic number of columns

    Hello,
    I'm pretty new to JSF. Currently I'm working on a project where I have to select a table from a list, and then make it browsable/editable. The problem I have is that the different tables also have a different number of columns.
    I have no problem displaying different tables if the number of coulumns stays the same (using h:datatable) but when it's dynamic, I don't know how I can have my JSP to adjust to support the varying number of columns.
    Has anyone got an example of dynamic datatable or maybe someone can point me in the right direction.
    Brimborian

    Hi daniel,
    1. There is an INDEPENDENT FORM
      whose inputs are FIELD LIST
      and from those, it consructs dynamic table.
    2. Here is the program.
    the dynamic table name will be
    <DYNTABLE>.
    3. U can use this program (FORM in this program)
    to generate any kind of internal table
    by specifying some inputs (ie. field list)
    4.
    REPORT abc.
    COMPULSORY
    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
    FIELD-SYMBOLS: <dynline> TYPE ANY.
    DATA: lt TYPE lvc_t_fcat.
    DATA: ls TYPE lvc_s_fcat.
    FIELD-SYMBOLS: <fld> TYPE ANY.
    DATA : fldname(50) TYPE c.
    PARAMETERS : infty(4) TYPE c OBLIGATORY.
    DATA : iname LIKE dd02l-tabname.
    START-OF-SELECTION.
    GET INFO
    CONCATENATE 'P' infty INTO iname.
    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
    EXPORTING
    tabname = iname
    TABLES
    ddfields = ddfields.
    CONSTRUCT FIELD LIST
    LOOP AT ddfields.
    ls-fieldname = ddfields-fieldname.
    APPEND ls TO lt.
    ENDLOOP.
    PERFORM
    PERFORM mydyntable USING lt.
    BREAK-POINT.
    INDEPENDENT FORM
    FORM mydyntable USING lt TYPE lvc_t_fcat .
    Create Dyn Table From FC
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
    FIELD-SYMBOLS: <fs_1>.
    FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
    DATA: lt_data TYPE REF TO data.
    ASSIGN lt_data TO <fs_data>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = lt
    IMPORTING
    ep_table = <fs_data>
    EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    Assign Dyn Table To Field Sumbol
    ASSIGN <fs_data>->* TO <fs_1>.
    ASSIGN <fs_1> TO <fs_2>.
    ASSIGN <fs_1> TO <dyntable>.
    ENDFORM. "MYDYNTABLE
    regards,
    amit m.

Maybe you are looking for

  • Restored system from Time Machine backup disk but the system could not start-up

    On MacBook Pro early 2008, restored the entire system from Time Machine backup disk to the entire disk. The previous system on the backup disk had FileVault turned on. The restore completed successfully and I was prompted to restart the system via th

  • Correct Order for BI+ services restart

    Hi All, We have the below services in BI+ What is the correct order to start them. Hyperion S9 BI+ 9.3 Core Services 1 Hyperion S9 BI+ 9.3 Interactive Reporting 1 Hyperion S9 BI+ 9.3 Financial Reporting Java RMI Registry Hyperion S9 BI+ 9.3 Financial

  • Nexuiz-2.5-2 to nexuiz-2.5.1 package patch

    This only concerns users who currently have nexuiz-2.5-2 installed. If you want to upgrade to 2.5.1 without downloading the full 600+ MB package, use the following PKGBUILD which uses the patch provided by Alientrap. # Contributor: Xyne # Contributor

  • Problem with "Show Format" bar in Mail

    The bold, italic, and underline buttons are not working on my "Show Format" bar in Mail. NOTHING will make them work: clicking on a button before I type: selecting/highlighting and then clicking on a button after I type; choosing command+I, command+B

  • Any samples for using JMX for displaying cluster statistics 3.6 ?

    Hi, Our Coherence 3.6 cluster is configured in the WLS domain and controlled using WLS node manager. This is all working well. We have created a WLS console extension to show the actual live cluster topology (rather than the configured topology) so w