Component binding inside h:dataTable fails

Hi,
I'd like to create a component binding for each commandLink to a distinct child bean inside an h:dataTable like so:
<h:dataTable value="#{parent.children}" var="child">
    <h:column>
        <h:commandLink binding="#{child.command1}" value="do it to it for #{child}" action="#{child.action}"/>
    </h:column>
</h:dataTable>But whenever I try to render this page I get an exception stating that "child is null" and binding cannot be performed. If I remove 'binding="#{child.command1}"', however, everything works fine. I guess this is happening because 'var="child"' in h:dataTable gets evaluated after bindings are created. How can I get around that - I really need to be able to refer distinctly refer to UIComponents in each row.
Confused...
thanks
-nikita

I created a seperate class to handle the requests ActivationRequestBuilder and put the code in there .
if you want to refer to each row in the backing bean .
create a variable of type HtmlDataTable .
private HtmlDataTable tenantDataTable;
set up accessor and mutator methods for this variable.
In your jsp in the DataTable
<h:dataTable binding="#{activationRequestBuilder.tenantDataTable}"
<h:commandLink title="Delete Tenant section"
immediate="true" action="#{activationRequestBuilder.deleteTenantLocationSection}">
public String deleteTenantLocationSection(){
(TenantLocationRecordBean) this.getTenantDataTable().getRowData();
This is just snippets of code but you should get the idea of what I have done here .I had multiple sections in a page so each row was a TenantLocationRecordBean .

Similar Messages

  • h:dataTable with component binding not rendering

    Hello,
    I am developing an application with several ad-hoc queries that need to be displayed in data table elements. The number and label values of the columns are not known until runtime. I am attempting to use a component binding mechanism to intercept the UIData and add columns to it at runtime, depending on the data currently held in a backing bean instance (such as an ad-hoc query result).
    I'm not sure where I can actually intercept the table and add the columns. I've got the following code example to compile and run without error, but nothing gets rendered properly - I get an opening <table> tag in the HTML source and nothing else follows.
    I have compared the structure of the table created with the following binding method to a table created with simple <h:dataTable> tags, and I see only one difference. The datatable created with tags has a single attribute in its attribute map called "javax.faces.webapp.COMPONENT_IDS" that maps to an ArrayList of the component IDs of the h:column elements I specify on the JSF page. The datatable I attempt to create in the binding method does not have this attribute in its map, and I can't seem to manually add it in without creating further havoc. (the child count, types of children, etc all seem to be equivalent).
    From the JSF perspective this is how I've defined the h:dataTable tag instance...
    <h:dataTable id="categoryTable" rendered="true"
            binding="#{backingBeanInstance.table}"
                value="#{backingBeanInstance.rows}"
                    var="row"  border="2" />This is basically the code in the backingBeanInstance....
        private UIData table;
        public void setTable(UIData table){
            this.table = table;
           //initTable();   //tried this but seems not to work either?
        public UIData getTable(){
            if(table!=null){
                initTable(); //build the columns and add to the table
            return table
        private void initTable(int categoryIndex){
                //This block is just a way to calculate the number of columns
                int colCount = <depends on data held in bean>
                //Resolve the var string for the data table
                String item = table.getVar();
                System.out.println("item: " + item);  //this is always null the 1st time through?? why?
                UIColumn col;
                UIOutput out;
                FacesContext context = FacesContext.getCurrentInstance();
                Application app = context.getApplication();
                //For each column in the data, create a UIColumn as child of the
                //data table.  Create a UIOutput as child of the UIColumn and bind
                //the value of the UIOutput to the data with an EL expression
                for (int j = 0; j < colCount; j++) {
                    //create an instance of UIOutput to display the value for this cell
                    out = new UIOutput();
                    out.setRendererType("Text");
                    //create an instance of UIColumn
                    col = new UIColumn();
                    //construct the value binding string as an EL expression
                    String valueBindingString = "#{" + item + "[" + j + "]}";
                    //create the value binding
                    ValueBinding vb = app.createValueBinding(valueBindingString);
                    //set the value binding on the UIOutput object
                    out.setValueBinding("value", vb);
                    //add the UIOutput component to the UIColumn as a child
                    col.getChildren().add(out);
                    //add the UIColumn to the data table as a child
                    table.getChildren().add(col);
        }

    <bump>

  • Can't use binding property of a commanButton inside a datatable

    I have commandButtons inside a datatable.
    The datatable is iterated over ArrayList containing custom PageSnippets objects, which look like this :
    public class PageSnippet {
              private int index = 0;
              private String name = null;
              private String id      = null;
              private UICommand upBtn = new UICommand();
              private UICommand downBtn = new UICommand();
              public PageSnippet (int index, String name, long id, int snippetCount) {
                   this.index = index;
                   this.name = name;
                   this.id = String.valueOf(id);
                   setBtnsVisibility(snippetCount);
               * getters
              public String getId() {
                   return id;
              public int getIndex() {
                   return index;
              public String getName() {
                   return name;
              public UICommand getUpBtn() {
                   return upBtn;
              public UICommand getDownBtn() {
                   return downBtn;
               * Sets button visibility.
              public void setBtnsVisibility (int snippetCount) {
                   upBtn.setRendered(index > 1);
                   downBtn.setRendered(index < snippetCount);
         }The two buttons are binded to the the pageSnippet's upBtn and downBtn objects in order to set their rendered status:
    <h:commandButton
    actionListener="#{pageEditBean.moveSnippet}" type="submit"
    image="../images/btn_up.png"
    binding="#{snippet.upBtn}"/>I got null nuinter exception, datable variable snippet is reported null
    and getter method of the backing bean getPageSnipets is not called at all.
    I got null nuinter exception even when rendered property of the datatable is false.
    When I remove binding property of the buttons everything works fine.
    When instead of binding property I use rendered property of the commandButton and in the getter metthods I return boolean:
    public boolean getUpBtn() {
                   return downBtn.isRendered();
              } Everything is OK as well.
    MyFaces 1.1.5
    JSDK 1.4.2_08
    Tomcat 4.1.3
    Have anybody encountered such problem?
    Is there any workaround?
    Or can anybody confirm that binding a commandButton to a backing UICommand object inside a datatable works for him?
    thanks in advance

    Thanks a lot.
    You're right, the backing bean has request scope.
    I found out (the hard way) that there's a bug in JSF that prevents a commandButton from working, when the button's rendered property is binded to a backing bean's property.
    But this solution works.
    But I got another problem:
    When I click the button, I got java.lang.NoSuchMethodError
    Even clicking the button outside the datatable returns the exception.
    Again, when I set the bean's scope to session it works.
    I don't understand that, except for the datatable business, commandButtons with other request scope beans work well.
    Thanks

  • How to get the column index inside a dataTable

    Hello,
    before I get staked, there are multiple threads handling familiar topics to the one I'm questioning about but none gives an anwer. If there is one, I'm propably to less skilled to see it.
    So here is my Problem: I've build a web-interface to a time-recording system. The hours worked on a certain project are displayed in a dataTable component which is generated out of a mySQL Query. Each entry (column/row) contains a inputText component to display and edit the specific value.
    Editing one of these inputText elements now fires a valueChangeEvent which reads the new value and stores it in the database. For that cause I need to know the row- and column-index of the inputText component that fired the event.
    Using the getClientId method from the valueChangeEvent I get some Information which makes it possible to calculate the row/column index. A typical clientID looks like "form_table:mainTable:0:_id14". "form_table" is the ID of the form the dataTable is in. "mainTable" is the id of the dataTable component. "0" is the row the component is in. And finally "_id14" stands for the id randomly given to the inputText component by JSF.
    My Problem is now, that though I can calculate the column out of the[i] "_id14", this calculation is hardcoded. So everytime I add a component in before the dataTable, the calculation needs to be adjusted in the code.
    The Questions:
    - How to force a sensefull id indicating a column-index for the inputText components inside the columns of a dataTable?
    - Nicer since no workaround: How to get the column-index inside the dataTable on a natural way? (e.g. out of the valueChangeEvent the specific inputText component fires)
    After some investigation here on the board and on the net I know multiple ways to get the row index, (Things like component-binding and so on) but I can't find a answer on how to get the column-index.
    Thanks to all answers and/or links to things my eyes missed while searching for one.

    ...then index 0 becomes index 1 and my program doesn't work properlyThe program works properly, just not as you expect it to.
    As you've noticed the table gives you the flexibility to move columns around. So if you move column 0 to column 1, why would you expect to still use 0 as the index? The table manages the reordering of columns for you to make sure the data being displayed in each table column comes from the correct column in the data model.
    You can manage this yourself using one of the following methods (I forget which one):
    table.convertColumnIndexToModel(int viewColumnIndex)
    table.convertColumnIndexToView(int modelColumnIndex)
    Or, you can get data from the data model directly:
    table.getModel().getValueAt(row, 0);

  • JSF Datatable inside a datatable problems

    Hi,
    i am having a datatable with 3 rows mapping to a column in the database table..now i have another datatable inside the previous datatable mapping to another column in the database.... i am able to fetch the values from the database and populate in the 2 datatables.my first datatable has one column and it is a component label.my second datatable has 4 columns..a select many checkboxes,a component label,and 2 text fields.
    Now the problem comes when i need to save the values that are being entered in the datatable..how do i get the values of the checkbox and the textfields and update in the database.and remember i need to get the values of all the components in both the datatables and update in the database...my JSP code and the backing bean codes are as follows.......pls help me with this problem
    JSP Code:
    <h:dataTable binding="#{AttributeSelection.uiTable2}" id="dataTable2" rowClasses="form"
    value="#{AttributeSelection.arrayDataModel}" var="currentRow1">
    <h:column binding="#{AttributeSelection.column5}" id="column5">
    <h:outputText binding="#{AttributeSelection.outputText1}" id="outputText1" value=""/>
    <f:facet name="header"/>
    <h:dataTable binding="#{AttributeSelection.uiTable1}" border="1" headerClass="form_bold"
    id="dataTable1" rowClasses="form" value="#{currentRow1['attributes']}" var="currentRow">
    <h:column binding="#{AttributeSelection.column1}" id="column1">
    <h:selectBooleanCheckbox binding="#{AttributeSelection.checkbox1}" id="checkbox1" value="#{currentRow.checkbox1}"/>
    <f:facet name="header"/>
    </h:column>
    <h:column binding="#{AttributeSelection.column2}" id="column2">
    <h:outputText binding="#{AttributeSelection.outputText3}" id="outputText3" value="#{currentRow['name']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText4}" id="outputText4"
    style="height: 23px; width: 50%" styleClass="form_bold" value="#{currentRow1['category']}"/>
    </f:facet>
    </h:column>
    <h:column binding="#{AttributeSelection.column3}" id="column3">
    <h:inputText binding="#{AttributeSelection.textField1}" id="textField1"
    style="height: 24px; width: 65%" styleClass="input" value="#{currentRow['defaultMin']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText8}" id="outputText8" value="Min"/>
    </f:facet>
    </h:column>
    <h:column binding="#{AttributeSelection.column4}" id="column4">
    <h:inputText binding="#{AttributeSelection.textField2}" id="textField2"
    style="height: 24px; width: 65%" styleClass="input" value="#{currentRow['defaultMax']}"/>
    <f:facet name="header">
    <h:outputText binding="#{AttributeSelection.outputText9}" id="outputText9" style="" value="Max"/>
    </f:facet>
    </h:column>
    </h:dataTable>
    </h:column>
    </h:dataTable>
    Backing Bean Code:
    * AttributeSelection1.java
    * Created on January 23, 2006, 10:46 AM
    * Copyright Sidharth_Mohan
    package tpalt;
    import com.equifax.ems.tpalt.order.dao.OrderDataDAO;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import com.sun.jsfcl.data.*;
    import java.util.ArrayList;
    import javax.faces.component.*;
    import javax.faces.model.ArrayDataModel;
    import com.equifax.ems.tpalt.order.model.OrderAttribute;
    import com.equifax.ems.tpalt.order.model.OrderCategory;
    import com.sun.faces.el.MethodBindingImpl;
    import java.util.Iterator;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.context.FacesContext;
    import javax.faces.el.MethodBinding;
    public class AttributeSelection extends AbstractPageBean {
    * Bean initialization.
    // </editor-fold>
    public AttributeSelection() {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
    try {
    } catch (Exception e) {
    log("AttributeSelection Initialization Failure", e);
    throw e instanceof javax.faces.FacesException ? (FacesException) e : new FacesException(e);
    // </editor-fold>
    // Additional user provided initialization code
    protected tpalt.ApplicationBean1 getApplicationBean1() {
    return (tpalt.ApplicationBean1)getBean("ApplicationBean1");
    protected tpalt.SessionBean1 getSessionBean1() {
    return (tpalt.SessionBean1)getBean("SessionBean1");
    // </editor-fold>
    * Bean cleanup.
    protected void afterRenderResponse() {
    }private int __placeholder;
    private HtmlForm form1 = new HtmlForm();
    public HtmlForm getForm1() {
    return form1;
    public void setForm1(HtmlForm hf) {
    this.form1 = hf;
    public UIData uiTable1 = new UIData();
    * Getter for property uiTable.
    * @return Value of property uiTable.
    public UIData getUiTable1() {
    return uiTable1;
    * Setter for property uiTable.
    * @param uiTable New value of property uiTable.
    public void setUiTable1(UIData uiTable1) {
    this.uiTable1 = uiTable1;
    private UIColumn column1 = new UIColumn();
    public UIColumn getColumn1() {
    return column1;
    public void setColumn1(UIColumn uic) {
    this.column1 = uic;
    private UIColumn column5 = new UIColumn();
    public UIColumn getColumn5() {
    return column5;
    public void setColumn5(UIColumn uic) {
    this.column5 = uic;
    private HtmlOutputText outputText1 = new HtmlOutputText();
    public HtmlOutputText getOutputText1() {
    return outputText1;
    public void setOutputText1(HtmlOutputText hot) {
    this.outputText1 = hot;
    public UIData uiTable2 = new UIData();
    * Getter for property uiTable.
    * @return Value of property uiTable.
    public UIData getUiTable2() {
    return uiTable2;
    * Setter for property uiTable.
    * @param uiTable New value of property uiTable.
    public void setUiTable2(UIData uiTable2) {
    this.uiTable2 = uiTable2;
    private ArrayDataModel arrayDataModel = new ArrayDataModel();
    public ArrayDataModel getArrayDataModel() {
    ArrayList orderList =new ArrayList();
    OrderDataDAO orderData =new OrderDataDAO();
    ArrayList orderCategories = new ArrayList();
    try
    orderList = (ArrayList) orderData.getAllAttributes();
    for (int i =0;i<orderList.size();i++)
    OrderAttribute or =(OrderAttribute)orderList.get(i);
    //or.setCheckbox1(true);
    String category = (String)or.getCategory();
    OrderCategory orderCategory = new OrderCategory();
    ArrayList attributesforCategory = new ArrayList();
    for (int j = i;j<orderList.size();j++){
    OrderAttribute ora =(OrderAttribute)orderList.get(j);
    if (category.equals(ora.getCategory())){
    attributesforCategory.add(ora);
    orderList.remove(j);
    j = i;
    orderCategory.setCategory(category);
    orderCategory.setAttributes(attributesforCategory);
    orderCategories.add(orderCategory);
    //dataTable2Model.setWrappedData(orderCategories);
    arrayDataModel = new ArrayDataModel(orderCategories.toArray());
    catch (Exception ex) {
    return arrayDataModel;
    public void setArrayDataModel(ArrayDataModel dtdm) {
    this.arrayDataModel = dtdm;
    private UIColumn column2 = new UIColumn();
    public UIColumn getColumn2() {
    return column2;
    public void setColumn2(UIColumn uic) {
    this.column2 = uic;
    private HtmlOutputText outputText3 = new HtmlOutputText();
    public HtmlOutputText getOutputText3() {
    return outputText3;
    public void setOutputText3(HtmlOutputText hot) {
    this.outputText3 = hot;
    private UIColumn column3 = new UIColumn();
    public UIColumn getColumn3() {
    return column3;
    public void setColumn3(UIColumn uic) {
    this.column3 = uic;
    private HtmlOutputText outputText4 = new HtmlOutputText();
    public HtmlOutputText getOutputText4() {
    return outputText4;
    public void setOutputText4(HtmlOutputText hot) {
    this.outputText4 = hot;
    private UIColumn column4 = new UIColumn();
    public UIColumn getColumn4() {
    return column4;
    public void setColumn4(UIColumn uic) {
    this.column4 = uic;
    private HtmlOutputText outputText8 = new HtmlOutputText();
    public HtmlOutputText getOutputText8() {
    return outputText8;
    public void setOutputText8(HtmlOutputText hot) {
    this.outputText8 = hot;
    private HtmlOutputText outputText9 = new HtmlOutputText();
    public HtmlOutputText getOutputText9() {
    return outputText9;
    public void setOutputText9(HtmlOutputText hot) {
    this.outputText9 = hot;
    public UIInput textField1 = new UIInput();
    public UIInput getTextField1() {
    return textField1;
    public void setTextField1(UIInput hit) {
    this.textField1 = hit;
    public UIInput textField2 = new UIInput();
    public UIInput getTextField2() {
    return textField2;
    public void setTextField2(UIInput hit) {
    this.textField2 = hit;
    public UISelectBoolean checkbox1 = new UISelectBoolean();
    public UISelectBoolean getCheckbox1() {
    return checkbox1;
    public void setCheckbox1(UISelectBoolean hsbc) {
    this.checkbox1 = hsbc;
    public String save_action() {
    try{
    java.lang.System.out.println("<<<<<<<<<<<<<<<Button Came<<<<<<<<<<<<<<<<<<>>>>>>>");
    java.lang.System.out.println("====================Welcome to the Button action======================");
    int firstIndex = uiTable2.getFirst();
    int rows = uiTable2.getRowCount();
    java.lang.System.out.println("----------------------FIRST INDEX-----------------------"+firstIndex);
    java.lang.System.out.println("----------------------ROWS-----------------------"+rows);
    ArrayList orderAttribs = orderCat.getAttributes();
    Iterator it = orderAttribs.iterator();
    while(it.hasNext())
    OrderAttribute currentAttribute = (OrderAttribute) it.next();
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getCheckbox1());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getName());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getDefaultMin());
    java.lang.System.out.println("==================String Value===================" + currentAttribute.getDefaultMax());
    catch (Exception e) {
    e.printStackTrace();
    return "Test";
    private HtmlCommandButton save = new HtmlCommandButton();
    public HtmlCommandButton getSave() {
    return save;
    public void setSave(HtmlCommandButton hcb) {
    this.save = hcb;
    Please Reply me with this solution soon.............
    Thanx,
    Sidharth
    }

    you may get some help in the following...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    -Regards,
    Aniruddha

  • Command Link inside of datatable

    I have the following problem when I put a command link inside a datatable.
    The action or actionlisteners never get called. Now here is the funny thing.
    1. If I move the action link outside the datatable it works.
    2. if I change the scope of the bean to session it works
    3. if the datatable contains more than 1 row it works
    The last one tells me this is a bug.
    To test this I change the sql query to limit the result so 1 row would be returned.
    The sql query returns a CachedRowSetImpl
    I believe this is a bug.
    <h:dataTable rows="6" first="0" id="table" binding="#{event.eventdata}" value="#{event.eventdetails}" var="eventdetail">
    <h:column>
    <h:commandLink value="#{eventdetail.title}" action="#{event.resaveEventaction}" actionListener="#{event.resaveEventdetails}" id="test" >
    </h:commandLink>     
    </h:column>
    <h:column>
    </h:dataTable>

    Here is some additional information that makes this more confusing.
    The following code is used to populate the datatable
    public CachedRowSetImpl getEventdetails(){
         CachedRowSetImpl rs2 = null;
         String selectedeventmy = selectedevent;
         int rowcount = 0;
         try { 
              sql = "SELECT * FROM event where eventid='"+selectedeventmy+"' ";
              rs2 = RunQuery.mysql(sql);
              rowcount = rs2.size();
         } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
         return rs2;
    where RunQuery.mysql is
    public class RunQuery {
         public static CachedRowSetImpl mysql(String sql) throws Exception {
              CachedRowSetImpl crset = null;
              InitialContext initCtx = new InitialContext();
              Context envCtx = (Context) initCtx.lookup("java:comp/env");
              try {
                   DataSource ds = (DataSource) envCtx.lookup("jdbc/associations");
                   Connection conn = null;
         Statement stmt = null;
         conn = ds.getConnection();
         stmt = conn.createStatement();
         stmt.execute(sql);
         ResultSet rs = stmt.getResultSet();
         crset = new CachedRowSetImpl();
         crset.populate(rs);
         rs.close();
         stmt.close();
         conn.close();
              } catch (Exception e) {
                   System.out.println(e.getMessage());
              return crset;
    if I replace the line
    String selectedeventmy = selectedevent;
    with String selectedeventmy = "61";
    it works properly.
    selectedevent is populated from the following triggered by another action event on another page. ? The funny thing is if the result set returns more that 1 row all works ok.
    public String viewDetails(){
         System.out.println("Running view Details");
         int selectedrow = eventlist.getRowIndex();
         Object selected = eventlist.getRowData();
         Map rowdata = (Map) selected;
         selectedevent = rowdata.get("eventid").toString();
         System.out.println("Selected Event:"+selectedevent);
         outcome="eventdetails";
         return outcome;
    }

  • Component binding table

    Hi,
    can someone give me an example of component binding with dataTable?
    In my app i must use this, because i don't know number of columns - so i must make table in my java code. Each column consists of checkbox and inputText and under the table is submit button which submits entire table. Values of checkbox and inputText in one column are bind to BackBean (this bean has selected value and price value).
    In my jsp, i use something like this:
    <h:dataTable var="table" binding="#{model.table}" value="#{model.data}" />
    I'm working on this for a week and I stil don't know how to do it.
    Thanks in advance,
    jarin

    Hi,
    yes U understand my problem. I have in my jsp only:
    <h:dataTable binding="#{model.table}"/>
    <h:commandButton action="#{model.set} value="submit"/>
    I use client state saving,
    model is managed bean ModelBean in request scope
    my two classes, which do all work - they should work if you get them into any app, I removed any unnecessary pieces of code:
    /* class ModelBean -------------------------------*/
    package backing.divadlo;
    import backing.divadlo.SedadloBack;
    import javax.faces.component.html.*;
    import java.util.*;
    import javax.faces.el.ValueBinding;
    import javax.faces.context.FacesContext;
    import javax.faces.component.*;
    public class ModelBean  {
      private UIData table;
      private ArrayList data;
      private int colNumber, rowNumber;
      public ModelBean() {
        table = new UIData();
        data = new ArrayList();
        colNumber = 0;
        rowNumber = 0;
      public void setData(ArrayList d) {
        this.data = d;
      public ArrayList getData() {
        return this.data;
      public void setTable(UIData tbl) {
        this.table = tbl;
      public UIData getTable() {
        init(); // normaly I call init() in another bean, if I select which auditorium will be shown
        return this.table;
      public void pripravData() {
        data.clear();
        // prepair of auditorium - get rows and number of cols
        rowNumber = 2;  // after all works, here will be rows of auditorium
        colNumber = 20; // seats in row, each row can have another number of seats
        // loop trough rows of auditorium
        for (int i = 0; i < rowNumber; i++) {
          ArrayList novaRada = new ArrayList();  // new row with seats
          // insert seats (SedadloBack) into new row
          for (int k = 0; k < colNumber; k++) {
            SedadloBack sedB = new SedadloBack(); // new seat
            sedB.setRada(k);      // set number of row
            sedB.setSedadlo(k);   // set number of seat
            sedB.setProdej(true); // is free or not
            sedB.setPrice(k);     // set price
            // insert seat into new row
            novaRada.add(sedB);
          // insert new row into auditorium
          data.add(novaRada);
      public void init() {
        FacesContext context = FacesContext.getCurrentInstance();
        List list = table.getChildren();
        list.clear();
        pripravData();
        if(data != null) {
          table.setValue(data);
          table.setRows(data.size());
          table.setRowIndex(0);
          table.setVar("dTable");
          UIColumn column;
          HtmlInputText priceText;
          HtmlSelectBooleanCheckbox checkbox;
          HtmlOutputText br1,br2,cislo;
          for (int i = 0; i < colNumber; i++) {
            column = new UIColumn();                    // new column
            priceText = new HtmlInputText();            // input for price
            checkbox = new HtmlSelectBooleanCheckbox(); // is free or not
            br1 = new HtmlOutputText();                 // <br>
            br2 = new HtmlOutputText();                 // <br>
            cislo = new HtmlOutputText();               // position of seat in row
            br1.setValue(new String("<br />"));
            br2.setValue(new String("<br />"));
            br2.setEscape(false);
            br1.setEscape(false);
            // prepare outText of position in row
            String cisloExp = "#{"+table.getVar()+"["+i+"].sedadlo}";
            ValueBinding vbCislo = context.getApplication().createValueBinding(cisloExp);
            cislo.setValueBinding("value",vbCislo);
            // prepare checkbox - if seat is free or not
            String expCheckbox = "#{"+table.getVar()+"["+i+"].prodej}";
            ValueBinding vbCheckbox = context.getApplication().createValueBinding(expCheckbox);
            checkbox.setValueBinding("value",vbCheckbox);
            // prepare inputText - price of seat
            priceText.setTitle("Cena");
            priceText.setStyleClass("cenaInput");
            String vbSIn = "#{"+table.getVar()+"["+i+"].price}";
            ValueBinding vbI = context.getApplication().createValueBinding(vbSIn);
            priceText.setValueBinding("value", vbI);
            // prepare column
            column.getChildren().add(cislo);
            column.getChildren().add(br1);
            column.getChildren().add(priceText);
            column.getChildren().add(br2);
            column.getChildren().add(checkbox);
            list.add(column);
      public String set() {
        // for now just print out price with position of seat
        for(int j=0; j < table.getRowCount(); j++) {
          table.setRowIndex(j);
          if(table.isRowAvailable()) {
            ArrayList data = (ArrayList)table.getRowData();
            for(int i=0; i < data.size(); i++) {
              SedadloBack sedadlo = (SedadloBack)data.get(i);
              System.out.println(sedadlo.getRada()+"/"+sedadlo.getSedadlo()
                                 +" - "+sedadlo.getPrice());
        return "null";
    /* class SedadloBack -------------------------------*/
    package backing.divadlo;
    import java.io.Serializable;
    public class SedadloBack implements Serializable {
      private int id;
      private int rada;
      private int sedadlo;
      private int price;
      private boolean prodej;
      public void setId(int id) {
        this.id = id;
      public int getId() {
        return this.id;
      public void setRada(int rada) {
        this.rada = rada;
      public int getRada() {
        return this.rada;
      public void setSedadlo(int sedadlo) {
        this.sedadlo = sedadlo;
      public int getSedadlo() {
        return this.sedadlo;
      public void setProdej(boolean pr) {
        this.prodej = pr;
      public boolean getProdej() {
        return this.prodej;
      public void setPrice(int price) {
        this.price = price;
      public int getPrice() {
        return this.price;
    } I realy appreciate your help, this is my first app in jsf - i make it as my dissertation and I am starting be little late.
    If you need more info or code i give you what you want. Preparing war is little complicated - I use postgres and hibernate and i doubt if you want install this db only to test my case.
    jarin

  • h:commandLink inside t:dataTable

    Hi ,
    I am using Tomahawk datatable and inside this datatable there is JSF HTML commandlink.
    when clicking the record in a datatable my action method is executing for multiple number of times. If there are four results present in datatable my action method is executing for four times. Is there any way to stop multiple calls and should execute only once.
    In JSP
    <t:dataTable id="searchProcCodeResults"     value="#{SearchRatesDataBean.searchResultList}"
              var="searchDetails" rows="10" >
    <h:column id="procCol">
         <h:commandLink id="edit"     action="#{SearchRateProcedureCodeControllerBean.getRatePCProvSpeDetails}">
              <h:outputText id="valueProc" value="#{searchDetails.procCode}" />
                   <f:param name="procedureCode" value="#{searchDetails.procedureCode}" />
                   <f:param name="providerSpecialtyCode" value="#{searchDetails.providerSpecialtyCode}" />
                   <f:param name="lobcode" value="#{searchDetails.lobCode}" />
         </h:commandLink>
    </h:column>
    </t:dataTable>

    take a HtmlDataTable refrece varible in your backing bean and create setter and getter method corresponding to it ,then bind this data table using the binding attibute in your jsp then you can can get the particular row data on calling getRowData() method on HtmlDataTable object and cast it to your's receiving object.

  • Component binding property problem

    following problem:
    I have a form where I built a dataTable with a dynamic number of columns. To achieve this, I used a component binding (backing bean) to dynamically add columns.
    The form is used for different kind of queries and every query has it's own number of columns. The query-identification is submitted via a request parameter.
    All the data in the query-form are o.k. (bean values) but the backing bean will not be called in case of a new request (same jsf-form, but other request-parameter).
    example:
    http://host/url.faces?id=1
    http://host/url.faces?id=2
    <h:dataTable id="test"
                 value="#{test.values}"
                 var="i"
                 rendered="true"
                 binding="#{test.table}">
    </h:dataTable>whereas test is a bean which is created in a servlet listener and also updated with the corresponding id from the request.
    The table-property depends on the id given in the request.
    why ?

    ok, I found out, that using the <h:commandLink> with a param-tag solves this issue.
    Now the backing-bean's method to build the table is all-time called.
    And it works even after an expired session.
    But unfortunately I do not really know, why it works this way and the other it doesn't...

  • ADFPhaseListener prepareRender and component binding problem

    I´m Using ADF Faces and using the ADFPhaseListener. My BackingBean extends from the PageController class
    and so can use prepareModel(LifecycleContext context) or prepareRender(LifecycleContext context). This works fine so far. The
    event handler methods are called as expected (in my example prepareRender). But I have one question.
    I´m using Component binding in my JSF-Page:
    <af:inputText binding="#{backing_untitled1.inputText1}" id="inputText1">
    Code snippet from my ControllerClass
    public class Untitled1 extends PageController{
    CoreInputText inputText1;
    public void setInputText1(CoreInputText inputText1) {   
    System.out.println("setInputText1");
    this.inputText1 = inputText1;
    public void prepareRender(LifecycleContext context) {
    super.prepareRender(context);
    System.out.println("inside prepareRender");
    I´ve written a second PhaseListener that just print´s out the JSF lifecycle phase numbers for better tracing.
    The first time I call my JSF-Page the following output is generated:
    07/01/03 08:32:38 Before Phase: 1 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:32:38 After Phase: 1
    07/01/03 08:32:38 inside prepareRender
    07/01/03 08:32:38 Before Phase: 6 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:32:39 setInputText1
    07/01/03 08:32:40 After Phase: 6
    I can see that the prepareRender is called before phase 6. The component binding is done in phase 6. What I would like to
    do is access the component binding in my prepareRender method. But this is not possible as it is null before phase 6.
    Is there a way to create event handling code after the component binding has taken place?
    When I do a postback (second call to the same JSF page) this thing changes
    07/01/03 08:37:23 Before Phase: 1 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 setInputText1
    07/01/03 08:37:24 After Phase: 1
    07/01/03 08:37:24 Before Phase: 2 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 2
    07/01/03 08:37:24 Before Phase: 3 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 3
    07/01/03 08:37:24 Before Phase: 4 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 4
    07/01/03 08:37:24 Before Phase: 5 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 5
    07/01/03 08:37:24 inside prepareRender
    07/01/03 08:37:24 Before Phase: 6 Source:com.sun.faces.lifecycle.LifecycleImpl@163
    07/01/03 08:37:24 After Phase: 6
    Here in my prepareRender method I could access the component binding as it has been initialized in phase 1.
    Thanks in advance
    Rainer

    hi, you can use this way to initially a value:
    public void setInputText1(CoreInputText inputText1) {
    this.inputText1 = inputText1;
    if( !AdfFacesContext.getCurrentInstance().isPostback() ){
    this.inputText1.setValue("somevalue");
    in the RenderModel phase is not possible set value to a component because this one is null, as you have said.. by this way you can do this too:
    public void setInputText1(CoreInputText inputText1) {
    this.inputText1 = inputText1;
    if( !AdfFacesContext.getCurrentInstance().isPostback() ){
    DCIteratorBinding ib = (DCIteratorBinding)Utilidades.resolveExpression("#{bindings.BanksView1Iterator}");
    RowIterator iter = ib.getRowSetIterator();
    Row row = iter.first();
    if (row != null){
    this.inputText1.setValue(row.getAttribute(BanksViewRowImpl.COD));}
    }

  • Problem in assigning id to DIV inside a datatable

    In our JSF application, we have a requirement to display a separate DIV for each row which is iterated inside a datatable.
    In order to display the contents under a particular DIV, we need to capture the id of that DIV.
    But since the DIV resides within verbatim inside the datatable, a unique identifier could not be associated to each DIV.
    The code looks like this�.
    <h:dataTable id="product_entity_data_table" width="690" border="0" cellspacing="1" columnClasses="clsTableBodyL"
    rowClasses="clsAlignTop clsListDarkBackground,clsAlignTop clsListLightBackground"
    headerClass="clsTableHeaderBottomL" value="#{entityImpactListBean.currentProductsDSIDetailBeanList}"
    var="productDSIDetail" rendered="#{impactListBean.entityProductFlag}">
    <h:column>
    <f:facet name="header">
    </f:facet>
    <h:panelGrid id="product_ent_dsidetail_newDataValue_pg" columns="1">
    <clsFields:radio id="dsi_newdatavalue" value="#{productDSIDetail.newProductValue}"
    onclick="formDivContent(#{productDSIDetail.productName}, #{productDSIDetail.dataLevelID}, this.id);">
    <f:selectItems value="#{impactListBean.radioValueList}" />
    </clsFields:radio>
    <h:outputText id="product_ent_dsidetail_errorMessage" styleClass="clsErrorMessageB"
    value="#{productDSIDetail.errorMsg}" rendered="#{productDSIDetail.errorMsgFlag}">
    </h:outputText>
    </h:panelGrid>
    <f:verbatim>
    <div id="div<%=divCount++%>" style="display:none;">
    <iframe name="frame<%=frameCount++%>" width="0" height="0" align="center"
    frameborder="0" onload='showData(this);'></iframe>
    </div>
    </f:verbatim>
    </h:column>
    </h:dataTable>
    Inspite of introducing divCount (code highlighted in blue), every time the id associated to every DIV is the same, which is �div1�.
    Any help in this regard will help us solve this issue.

    Hi ,
    If your are not sure about user name , use the wildcard pattern , but make sure you use only a single *
    i.e
    1)IF User = shilpa*
    THEN Portal Desktop = dekstop path
    2)IF User =*  shilpa  *
    THEN Portal Desktop = dekstop path
    Here 1st option will work , 2nd will not work. "  use only a single *   "
    Regards,
    Sunitha Hari

  • TS1717 Can't open iTunes, keeps getting this error "iTunes.exe - Unable to locate component. This application has failed to start because MSVCR80,dll was not found"

    Can't open iTunes, keeps getting this error "iTunes.exe - Unable to locate component. This application has failed to start because MSVCR80,dll was not found"

    Solving MSVCR80 issue and Windows iTunes install issues.

  • Error: Sender agreement not found, lookup of binding via CPA-CACHE failed.

    Hi,
    I am doing an RFC to File Scenario in which RFC has to be triggered from CRM system. The TCP/IP connection and communication Channel are working fine. But when i trigger my RFC using the RFC destination following errors occur:
    1. The SYSTEM_FALIURE exception comes on CRM side.
    2. In adapter monitoring the following error comes on XI side:
           Error: Sender agreement not found, lookup of binding via CPA-CACHE failed for Adapter type RFC.
    I have also tried the scenario with RFC request as source message and also after J2EE cache refresh but the problem still persists. And one more thing my file adapter (In receiver communication channel) is not working means it is not started. And no message is coming in SXMB_MONI.
    Could anyone please help me to resolve this issue.
    Regards,
    Vinay Yadav

    Hi Aaron,
    I had the same error and your feedback solved my problem!
    Thank you sooo much!!!!
    Luciana

  • How to use h:selectOneRadio tag  inside h:dataTable tag

    Hi All,
    Can any one tell me how to use <h:selectOneRadio> tag inside <h:dataTable> tag and how to get selected radio button value in bean ?

    JSF<h:selectOneMenu value="#{myBean.selectedItem}">
        <f:selectItems value="#{myBean.selectItems}" />
    </h:selectOneMenu>MyBeanprivate String selectedItem;
    public String getSelectedItem() {
        return selectedItem;
    public void setSelectedItem(String selectedItem) {
        this.selectedItem = selectedItem;
    public List getSelectItems() {
        List selectItems = new ArrayList();
        selectItems.add(new SelectItem("key1", "value1"));
        selectItems.add(new SelectItem("key2", "value2"));
        selectItems.add(new SelectItem("key3", "value3"));
        return selectItems;
    }String selectedItem should contain the key (key1, key2 or key3) when selected. The values (value1, value2 and value3) are the options as shown in the list.

  • "senderAgreement not found: lookup of binding via CPA-cache failed for..."

    Hi,
         I have configured asynchronous sender RFC to JDBC scenario and when I execute RFC I get short dump "senderAgreement not found: lookup of binding via CPA-cache failed for..."
         My scenario configurations, RFC destination, are all okey..
    A Hint:
         Our XI Server is "LARA"
         Our R/3 4.6C Server is "ZULIA"
    This are the RFC Sender Communication Channel on LARA:
         RFC Server Parameter
         Application Server (Gateway):           ZULIA
         Application Server Service (Gateway):      sapgw00
         Program ID:                     DEV210
         SNC:                          NOT CHECKED
         UNICODE:                     NOT CHECKED
         Inital Connections:               10
         Maximum Connections:               10
         Advanced Mode:                    NOT CHECKED
         RFC Metada Repository Parameter
         Load Balancing:                NOT CHECKED
         Application Server:               ZULIA
         System Number:                    00
         Authentication Mode:               Use Logon Data for SAP System
         Logon User:                    ldiego
         Logon Password:                    **********
         Logon Language:                    ES
         Logon Client:                    210
         Adapter-Specific Message Attributes
         Set Adapter-Specific Message Attributes: NOT CHECKED
    This are the configuration of RFC Destination on ZULIA:
         RFC Destination Name:                XI_RFC
         Connection Type:               T
         ID Program:                    DEV210
         Host Gateway:                    ZULIA
         TCP Service                    sapgw00
    Must I create the RFC Destination on the JCo RFC Provider in Visual Administrator?

    <i>Is the RFC destination created in the R/3 is pointing correctly to the XI system and vice -versa. Test the connection.</i>
    I tested my RFC Destination from R/3 system and the response was successful. What do you mean about vice-versa? How do I test it in the other way?.
    I recreate my Sender Agreement. And my Business System is correct.
    This are the parameters of my Sender Agreement:
    Service:     DES210_DEV
    Interface:     Z_DATOS_SAP
    Namespace:     urn:sap-com:document:sap:rfc:functions
    Sender Communnication Channel: cc_s_rfc_dataCom
    When I execute the FM in R/3 the dump now is:
    Wrong Sender Agreement:The Sender agreement does not have channel

Maybe you are looking for