Hibernate datatable component

Hi,
I'm building a component to display a datatable from a hibernate select statement. I want to have pagination and a sorting mechanism.
The problem now is that my component goes two times to the database. First time when he restores my view (lifecycle 1) and secondly when he creates my response (lifecycle 6).
I'm sure somebody was before me to create a component like this, but I can't find docs on the internet. Does somebody know where I can find a component like this. Note, I don't want to use spring, keep it clean only JSF and hibernate.
Thx in adv,
Pieter

hi;
actually you should not make a db connection in restoreview Phase, instead restore your datasource from the viewstate
in your components encoding phase you should make db queries.
please take look to the following code.
@Override
public Object saveState(FacesContext context) {
Object values[] = new Object[2];
values[0] = super.saveState(context);
values[1] = label;
return ((Object) (values));
@Override
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[])state;
super.restoreState(context, values[0]);
label = (String)values[1];
http://asahin.net

Similar Messages

  • Jsf datatable component + java.sql.SQLException

    I get the following error when implementing a JSF DataTable component using
    JDeveloper 10.1.3.1.
    javax.faces.FacesException: java.sql.SQLException: Io exception: Socket closed
    I am able to follow the article in this link:
    http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html
    I can get the table generated, but it occurred to me that the example in this article does not include logic to close the statement, resultset, and connection. Sure enough, I jumped out to the database and there were numerous inactive connections hanging around from my application.
    I added the following code before the return null statement from the article:
    finally {
    try {
    rs.close();
    stmt.close();
    c.close();
    catch (Exception e) {
    System.out.println("after close");
    So I need to know the proper procedure to closing the resultset, statement, and connection using a jsf datatable component.

    You need to make sure you're using the Oracle9i JDBC driver, or using the Oracle 8.1.7.2 JDBC driver as I mentioned above.
    If you are using JDeveloper9i release 9.0.2 or 9.0.3, the driver you need is in <jdevhome>\jdbc\lib
    Otherwise, you can also download the drivers from OTN.

  • How to bind table data to datatable component and show all the table data??

    I bind table to datatable component !
    The datatable has four rows,
    but the datatable alway show the first row data in its four rows,why??

    do you mean at design time or at runtime?
    at design time, the datatable uses generic fields to
    show if data type is numeric, text, date, etc...
    If this is at runtime,
    - what driver are you using?
    - how did you bind the data to the table?
    - what is the resulting code in the Java backing file?
    hth,
    -Alexis

  • Displaying ResultSet in DataTable component

    Say my program codes have created a ResultSet object by applying some SQL query into the database tables.
    Now I just want to display the contents of that ResultSet object in the JSC DataTable component. Is it possible? If so, how?
    Thank you.

    Hi,
    I think i have found a way to do what we want to do :
    As written in Winston Prakash's Weblog (http://blogs.sun.com/roller/page/winston),
    1) I have created a java class "ResultRowDataProvider" that extends ListObjectDataProvider and that contains a method that fill a list from the resultset. (Later, this list will be automatically used to fill the Table Component)
    That is to say :
    public class ResultRowDataProvider extends ObjectListDataProvider{
    private List resultList = new ArrayList();
    /** Creates a new instance of ResultRowDataProvider */
    public ResultRowDataProvider() {
    setUserResizable(true);
    public void fillResultList(ResultSet rs){
    try{
    rs.beforeFirst();
    while(rs.next())
    resultList.add(new ResultRow(rs.getString(1), rs.getString(2)));
    } catch(SQLException sqle){}
    setList(resultList);
    public int getNbRows(){
    return this.resultList.size();
    2) I have created a java class "ResultRow" where I defined private attributes that the ResultRowDataProvider will provide.
    That is to say :
    public class ResultRow(){
    private String field1;
    private String field2;
    public ResultRow(String field1, String field2){
    this.field1 = field1;
    this.field2 = field2;
    public String getField1(){
    return this.field1;
    public String getField2(){
    return this.field2;
    public void setField1(String field1){
    this.field1 = field1;
    public void setField2(String field2){
    this.field2 = field2;
    3) I finally added the following line to the init( ) method in SessionBean1.java :
    resultRowDataProvider = new ResultRowDataProvider();
    Then it is compulsory to clean and build the project, to close the project and to reopen it so that the table component layout will take into account the ResultRowDataProvider.
    I chose it, but it didn't display the two fields I defined (field1 and field2)
    whereas Winston said it should display them. So I defined the table columns myself using as value : #{currentRow.getValue('field1')} for the field1 column.
    It worked at runtime.
    Now jetsons, I would like to tell you that I personnaly wanted to fill programmatically the Table Component because I am using an Oracle 9.2.0.1 database. In the first version of my project, i used the CachedRowSet. Then I read that i had to use OracleCachedRowSet using ocrs12.jar. But after many bugs at runtime, I had a look to forums and I read that :
    "JDBC drivers provided by Oracle are not suitable for Sun Java Studio Creator, and are not supported. Oracle drivers currently available do not fully implement the JDBC 3.0 Specification. Sun Java Studio Creator requires certain schema information at design time that Oracle drivers do not provide."
    In fact we can use DataDirect but ...
    Filling programmatically a Table Component is a database-independant way ;)
    Thank you for your help jetsons and MISS_DUKE.

  • Multiple DataSourceRef in DataTable component

    Dear All,
    I'm a newbie using JDeveloper 9.0.3 to develop a JSP application. I wonder if I can pass more than one DataSource to the DataTable component so that I can customize the component to get data from to DataSourceRef. Can anybody help?

    Dear All,
    I'm a newbie using JDeveloper 9.0.3 to develop a JSP application. I wonder if I can pass more than one DataSource to the DataTable component so that I can customize the component to get data from to DataSourceRef. Can anybody help?

  • Jsf datatable inside datatable component rendering problem.

    I am creating an online survey application using JSF with IceFaces component library. The survey can have any number of questions. Each question can be any one of the types checkbox, radio button, etc with multiple options.
    For this, I am using a datatable to dynamically add a question to the survey. Inside that datatable, I am using another datatable to add option to the survey.
    Now the problem is, if I keep on click on add question button, in the outer data table, question is being added without any issue. Once I click on inner data table to add a option to any of the added questions, I am able to add. But after that, if I click again on add question button, it is not working.
    This is my xhtml code:
    <ice:dataTable id="icePnlQuestionAdd" var="questAdd" value="#{createSurveyManagedBean.surveyQuestionList}">
    <ice:column>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <th><ice:outputText value="Question English" style="white-space: nowrap;" /></th>                                        
    <td colspan="15">                              
    <ice:inputText id="QuestionEn" style="width:485px;" value="#{questAdd.questionEn}" />
    </td>
    </tr>
    <tr>
    <ice:dataTable id="icePnlOptionAdd" var="optionAdd" value="#{questAdd.surveyQuestionOptionList}">                               <ice:column>
    <th><ice:outputText value="Option " /></th>
    <td><ice:inputText id="OptionEn" value="#{optionAdd.optionEn}" /></td>
    </ice:column>
    </ice:dataTable>
    </tr>
    </table>
    </ice:column>
    </ice:dataTable>
    This is the add question method:
    public String addQuestion() {
    SurveyDTO addSurveyQuestionDTO = new SurveyDTO();          
    questionNum = surveyQuestionList.size();          
    addSurveyQuestionDTO.setQuestionNum(questionNum);
    surveyQuestionList.add(addSurveyQuestionDTO);
    return "createSurvey";
    This is the add option method:
    public String addOption() {
    FacesContext context = FacesContext.getCurrentInstance();          
    if (context.getExternalContext().getRequestParameterMap().get("questionNum") != null) {
    String questionNum = (String) context.getExternalContext().getRequestParameterMap().get("questionNum");
    int selectedQuestionNum = Integer.valueOf(questionNum);                    
    SurveyQuestionOptionDTO surveyQuestionOptionDTO = new SurveyQuestionOptionDTO();
    surveyQuestionList.get(selectedQuestionNum).getSurveyQuestionOptionList().add(surveyQuestionOptionDTO);
    return "createSurvey";
    }

    Bind the h:datatable in the jsp to UIDataTable component in your java code. Then when the action method is invoked, use DataTable.getWrappedObject() to get the model. Cast the model to whatever your type is (List, Array...) and then iterate through the model to process individual rows.

  • Create a datatable component

    I want to create a HtmlDataTable component in my java code.
    I do this at the moment, but seems that nothing happens:
    FacesContext context = FacesContext.getCurrentInstance();
            Application app = context.getApplication();
            HtmlDataTable table = (HtmlDataTable) app.createComponent(HtmlDataTable.COMPONENT_TYPE);
            UIColumn column = (UIColumn) app.createComponent(UIColumn.COMPONENT_TYPE);
            HtmlOutputLink link = (HtmlOutputLink) app.createComponent(HtmlOutputLink.COMPONENT_TYPE);
            HtmlOutputText text = (HtmlOutputText) app.createComponent(HtmlOutputText.COMPONENT_TYPE);
            context.getViewRoot().getChildren().add(table);
            table.getChildren().add(column);
            column.getChildren().add(link);
            link.getChildren().add(text);
            table.setVar("item");
            table.setValueBinding("value", app.createValueBinding("#{menuBean.myList}"));
            link.setValue("#");
            text.setValueBinding("value", app.createValueBinding("#{item}"));What is wrong?

    You create a new table as a child of UIViewRoot.
    But UIViewRoot's rendersChildren property is false;
    that means encodeChildren method is not invoked.
    Encodeing of other components under <f:view> is done by the corresponding
    Tag Handler; whereas your new table has no corresponding one.
    I think you should create a new table under some component
    whose rendersChildren property is true (e.g. PanelGrid).

  • Rules property in the JSF dataTable component

    Does anyone know how to use this or if there is any documentation on how to use this? Is this how one can, for example, create rows of subtotals?
    Any assitance would be greatly approciated.
    Thanks
    =========================================================
    <h:dataTable value="#{ObjectSearchBackingBean.ota}" var="ot"
                               id="searchResults" rendered="true"
                               binding="#{ObjectSearchBackingBean.searchResults}" cellpadding="3" cellspacing="0"
                               styleClass="dataTable" headerClass="dataTableHeader"
                               rowClasses="dataTableRowWhite,dataTableRowGrey"
                               rules="groups">

    rules attribute:
    "Code specifying which rules will appear between cells within this table. Valid values are: none (no rules, default value); groups (between row groups); rows (between rows only); cols (between columns only); and all (between all rows and columns)."

  • How to link dataTable component with Microsoft Access Database?

    Please mail me @ [email protected]

    Creator might not support MS Access yet but use this code for an access database connection will always work even through notepad or textpad:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.Properties;
    * @author Mark Hennessy
    public class MyDataSource {
    private static MyDataSource ds = null;
    private static java.sql.Connection connection = null;
    /** Creates a new singleton instance of MyDataSource */
    private MyDataSource() {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = java.sql.DriverManager.getConnection("jdbc:odbc:<db name>", "guest", "guest");
    }catch(ClassNotFoundException cnf){
    cnf.printStackTrace();
    }catch(java.sql.SQLException sqle){
    sqle.printStackTrace();
    public static DataSource getInstance() {
    if(ds == null)
    ds = new DataSource();
    return ds;
    public java.sql.Connection getConnection() {
    return this.connection;
    public static void closeConnection() {
         try{
              connection.close();
         }catch(java.sql.SQLException sqle){
              sqle.printStackTrace();
    plus set up the ODBC connection via click start , click run and then copy and paste the following "odbcad32.exe" without the quotes, click ok, click user DSN tab, click Add...button select Microsoft Access Driver (*.mdb) click finish, give <db name> name of ur access database, give any description <whatever> or leave blank click the select... button navigate to the access database u want to connect to in your java code and select it.
    in calling program
    public class CustomersImplimentation {
    private static java.sql.Connection connection = null;
    private java.sql.ResultSet rs = null;
    public CustomersImplimentation(){
    connection = MyDataSource.getInstance().getConnection();
    public Customers[] findAll(){
    java.util.ArrayList list = new java.util.ArrayList();
    String sql = "SELECT * FROM CUSTOMERS";
    try{
    java.sql.Statement stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    while(rs.next()){
    list.add(new Customers(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }catch(java.sql.SQLException sqle) {
    System.out.println((new StringBuilder()).append(
    "SQLException :: executeQuery Cannot find all Customers:").append(sqle).toString());
    Customers[] customers = new Customers[list.size()];
    for(int i = 0; i < list.size(); i++){
    customers[i] = (Customers)list.get(i);
    return customers;
    if you have a Customers class created with set and get methods and a constructor that takes an int string string i.e.
    public Customers(int ID, String firstName, String lastName){}
    then u should be able to run these classes from within creator with an access database. hope this helps?
    regards
    Henno

  • JSF + Hibernate - non- persistant objects in a dataTable

    This is more of a conceptual question, concerning creating a dataTable from a list.
    I have a User-with-Projects 1:M relationship. Projects are obligatory and not obligatory. I have a user with one compulsory project and a 5 not obligatory. The point is that the 6 projects should be visible in the UI under a h:dataTable component while each inputText from the dataTable should be mapped to beans. The obligatory project is always persisted in the DB, but the others are persisted only if data is inserted in the UI.
    So my question is:
    How could I form a dataTable, including the 6 project, and check if a data is inserted in the not-compulsory ones?
    I tried to create a User object with 6 Project entities (pojo classes), the first one is persisted in the DB and the others are not. This way I had a problem with the lack of ProjectID in the 5 remaining projects (since they are not a part of the DB). The issue could be elsewhere, but that's a rock I hit.
    I'll also try creating a ProjectBean with 6 project, on a form submit checking each of the rows for a new data. If user input is available, the project would be inserted in the table. I could also try using an actionListener to check for the input, but I'm not quite sure of getting the correct row I need when the listener is active.
    Is there any elegant way of mapping the projects and insert the not- obligatory only if they contain data?
    Thanks in advance,
    nofearinc

    >
    Straightforward enough: check if the values aren't null ;) You can also consider to add a valueChangeListener to one or more fields. It would only be fired if the field's value has been changed.
    Thanks for the comment, It was just weird for me how to have a User with a List<Project> and not all of the projects are persisted :) It seems a little strange for me as a realization and I assume that Hibernate would also be confused after session saving. That's why I think that I'll need a list of backing beans which would lately be transfered to entities if data is persisted (just being curious if there is more easy and elegant way to do that).
    The valueChangeListener would be called after any data is inserted in the row - it's possible that a user could go wrong and edit a field, then erase it again. So I have to insert in the DB only on a form submit (less DB activity).
    I'll try this getRowData() method tomorrow, it seems like a reasonable solution if I could use it in my case (dataTable with list of projects and get each row as a particular project).
    Thanks again for the reply, I'd be happy to hear any ideas on the subject ;)
    nofearinc

  • SaveState and resetState only called once for a component in a dataTable?!

    I am fairly new to JSF and am trying to write some custom components using MyFaces 1.0.9.
    I am trying to write choose, when and otherwise components to mirror the functionality that XSL provides. I also created function and argument tags that allow me to call any method on a binding bean via a method binding. The when tag allows a function tag as a child so that instead of a test to a value binding, I can call a function on a bean to get the test value.
    Example:<x:choose>
    <x:when>
      <x:function name="#{myBean.myFunction}">
       <x:argument value="testValue" />
       <%-- I will render some components here --%>
      </:x:function>
    <x:otherwise><%-- here is the else components to render --%></x:otherwise>
    </x:choose>I am evaluating the UIWhen components in the encodeChildren method of my UIChoose component.
    Everything is working fine until I started using my tags/components in a data table. Now, I have not tried the normal dataTable, I am using the MyFaces extended one, but I haven't done anything that should make a difference.
    What is happening is that my UIWhen tag's saveState and restoreState methods are only being called once, despite the fact that there are 3 rows in my data table. So what happens, is that the isRendered() property of my UIWhen component is not restored per row, but only once. So my controls are either all validated or none are validated based on the rendered state of the last row only, not each individual row as expected.
    I may be able to "fake" this into working by saving hidden input tags when rendering my UIWhen components and then restoring the rendered property when the page is posted, but that seems like a hack to me. Isn't the purpose of the saveState and restoreState supposed to handle this?
    Is this a bug in the dataTable component/tag or is this a shortcomming of JSF?
    Either way, is there a better way then trying to save my rendered state per row as hidden elements?
    I looked at the code of the normal dataTable renderer in the MyFaces source, and it does not seem to call restore or save state that I could see.
    Thanks for the help,
    Andrew

    Hello!
    You can place in the data model editor formula and placeholder
    columns outside of any groups. I think you need for each of your
    summary-attibutes a placeholder column and one formula column.
    Use the formula column to populate the placeholders via PL/SQL.
    Afterwords you can reference the placeholders anywhere you want.
    Regards,
    Hajo Winkler

  • Problem with inputText in my custom component

    Hi, I have a custom dataTable component that I'm trying to get to work. It has to be a custom component because dataTable doesn't support rowspan, colspan, multi line headers, and a rendered attribute for rows. The problem is, that when I wrap the column tag inside my row tag then the method for the inputText tag never gets called in the UPDATE_MODEL_VALUES phase.
    I'm starting to think that JSF doesn't support 2 levels of tags between the inputText and dataTable. I'm hoping that someone can tell me what I have wrong with my components.
    Here is the JSP snippet.
    <cjsf:rptTable>
         <cjsf:data id="dataTable1" value="#{allAuthUser.tableRows}" var="myTableRow1">
              <cjsf:row>
                   <cjsf:col>
                        <h:inputText id="tableTestFld" value="#{myTableRow1.testFld}" size="5" maxlength="5"/>
                   </cjsf:col>
              </cjsf:row>
         </cjsf:data>
    </cjsf:rptTable>Here is what it renders. It looks to me like everything renders fine. So I'm guessing that there is something in a component that is causing JSF during the life cycle to not be able to process correctly.
    <table>
         <tbody>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_0:tableTestFld" name="tblmaintForm:body:dataTable1_0:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_1:tableTestFld" name="tblmaintForm:body:dataTable1_1:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_2:tableTestFld" name="tblmaintForm:body:dataTable1_2:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
         </tbody>
    </table>Note: If I leave off the row tag it renders the same way except of course the <tr> and </tr> tags are missing. If I do this, then the backing method for the inputText tag is called and everything works fine. Why doesn't it work with the row tag in place?
    Here are the components:
    public class UIRptTable extends UIComponentBase {
         public UIRptTable() {
              setRendererType("tblmaint.rptTableRenderer");
         public String getFamily() {
              return "javax.faces.Output";
    public class UIRptTableData extends HtmlDataTable {
         public UIRptTableData() {
              setRendererType("tblmaint.rptTableDataRenderer");
         public String getFamily() {
              return "javax.faces.Data";
    public class UIRptTableRow extends UIOutput {
         public UIRptTableRow() {
              setRendererType("tblmaint.rptTableRowRenderer");
         public String getFamily() {
              return "javax.faces.Output";
    public class UIRptTableCol extends UIColumn {
         public UIRptTableCol() {
              setRendererType("tblmaint.rptTableColRenderer");
         public String getFamily() {
              return "javax.faces.Column";
    }Here is part of the faces-config file in case you need it.
    <!-- Components -->
    <component>
         <component-type>tblmaint.rptTable</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTable</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableData</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableData</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableRow</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableRow</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableCol</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableCol</component-class>
    </component>
    <!-- Render Kits -->
    <render-kit>
         <renderer>
              <component-family>javax.faces.Output</component-family>
              <renderer-type>tblmaint.rptTableRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Data</component-family>
              <renderer-type>tblmaint.rptTableDataRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableDataRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Output</component-family>
              <renderer-type>tblmaint.rptTableRowRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableRowRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Column</component-family>
              <renderer-type>tblmaint.rptTableColRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableColRenderer</renderer-class>
         </renderer>
    </render-kit>I sure hope that someone can help me out. Please let me know if you need any additional information.
    Thanks,
    Ray

    Hi, Ray!
    1) I was trying to put a button in the column header (for sorting) and I couldn't get that to work. That involved the >colhdr tag. I got that to work but I don't remember the fix. I'll look it up and reply back with that when I can.Dealing the first part of your trouble, you need NOT a custom component.
    I have looked through the implementation of RepeaterRenderer, as you advised me, and found that the multi-header possibility is included in the implementation of dataTable control.
    The code below is the part of source of repeater.jsp with only change:
    <d:data_repeater> &#61664; <h:dataTable>
    And it works fine.
    <h:dataTable id="table"
    binding="#{RepeaterBean.data}"
         rows="5"
    value="#{RepeaterBean.customers}"
    var="customer">
    <f:facet name="header">
    <h:outputText value="Customer List"/>               <!� First Header row -- >
    </f:facet>
    <h:column>
    <%-- Visible checkbox for selection --%>
    <h:selectBooleanCheckbox
    id="checked"
    binding="#{RepeaterBean.checked}"/>
    <%-- Invisible checkbox for "created" flag --%>
    <h:selectBooleanCheckbox
    id="created"
    binding="#{RepeaterBean.created}"
    rendered="false"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Account Id"/>               <!�Second Header row -- >
    </f:facet>
    <h:inputText id="accountId"
    binding="#{RepeaterBean.accountId}"
    required="true"
    size="6"
    value="#{customer.accountId}">
    </h:inputText>
    <h:message for="accountId"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Customer Name"/>               <!�Second Header row -- >
    </f:facet>
    <h:inputText id="name"
    required="true"
    size="50"
    value="#{customer.name}">
    </h:inputText>
    <h:message for="name"/>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Symbol"/>
    </f:facet>
    <h:inputText id="symbol"
    required="true"
    size="6"
    value="#{customer.symbol}">
    <f:validateLength
    maximum="6"
    minimum="2"/>
    </h:inputText>
    <h:message for="symbol"/>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Total Sales"/>
    </f:facet>
    <h:outputText id="totalSales"
    value="#{customer.totalSales}">
    <f:convertNumber
    type="currency"/>
    </h:outputText>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Commands"/>
    </f:facet>
    <h:commandButton id="press"
    action="#{RepeaterBean.press}"
    immediate="true"
    value="#{RepeaterBean.pressLabel}"
    type="SUBMIT"/>
    <h:commandLink id="click"
    action="#{RepeaterBean.click}"
    immediate="true">
    <h:outputText
    value="Click"/>
    </h:commandLink>
    </h:column>
    </h:dataTable>
    You may have a look at HTML source to prove that dataTable is already what you need:
    <table id="myform:table">
    <thead>
    <tr><th colspan="6" scope="colgroup">Customer List</th></tr>
    <tr>
    <th scope="col"></th>
    <th scope="col">Account Id</th>
    <th scope="col">Customer Name</th>
    <th scope="col">Symbol</th>
    <th scope="col">Total Sales</th>
    <th scope="col">Commands</th>
    </tr>
    </thead>
    <tbody>
    2.) The second trouble is still unsettled as previously. Right now I have different task at my job, and I can�t continue investigation of this problem.
    But when you find smth., please let me know. I�ll be very grateful.
    Regards,
    Oleksa Stelmakh

  • Deleting a single row from a dataTable / database

    Hi,
    I am fairly new to JSF so please bear with me if the answer is obvious :D. I'm using a dataTable component to display data from a database and would like to add a commandLink component to every row in the table that deletes that row from the database. What is the most effective way of doing this?
    I'm thinking of using a ListDataModel with some function that removes the correct row (though I'm not sure how it will tie in with a commandLink and exactly where the database will be updated). I'll appreciate any pointers or perhaps even an online example of something similar.
    Alternatively I suppose you could pass an "id" parameter on with the commandLink that somehow gets read in the request and the appropriate row is removed accordingly. This solution seems cumbersome however.

    jabalsad wrote:
    Hi,
    I am fairly new to JSF so please bear with me if the answer is obvious :D. I'm using a dataTable component to display data from a database and would like to add a commandLink component to every row in the table that deletes that row from the database. What is the most effective way of doing this?
    I'm thinking of using a ListDataModel with some function that removes the correct row (though I'm not sure how it will tie in with a commandLink and exactly where the database will be updated). I'll appreciate any pointers or perhaps even an online example of something similar.
    Alternatively I suppose you could pass an "id" parameter on with the commandLink that somehow gets read in the request and the appropriate row is removed accordingly. This solution seems cumbersome however.Yes, your instincts are correct there. Binding the data model to a backing bean to get the UIData instance for the table. Then use UIData.getRowData() to get the object corresponding to the row containing the link/button. Then execute your business logic to delete the row from the database. Then you need to ensure the data model is updated to reflect the new state of the database.

  • How to find out row that was clicked in DataTable?

    Hi there,
    i have a dataTable component which renders a list from database. In the last column of this table you can click a link for further processing for this row.
    How to identify which row was clicked?
    <f:view>
         <h3>Subtitel</h3>
         <h:form>
           <h:dataTable      headerClass="tableheader"
                             var="list"
                             value="#{Uebersicht.uebersichtsliste}">
              <h:column>
                   <f:facet name="header">
                        <f:verbatim>KW</f:verbatim>
                            </f:facet>
                           <h:outputText value="#{list.cal.kw}" />
              </h:column>
              <h:column >
                   <f:facet name="header">
                        <f:verbatim>Bemerkung</f:verbatim>
                            </f:facet>
                   <h:outputText value="#{list.cal.feiertagNat}" />
              </h:column>
              <h:column >
                   <f:facet name="header">
                        <f:verbatim>Start</f:verbatim>
                            </f:facet>
                   <h:commandLink action="#{Uebersicht.start}" value="setzen"/>
              </h:column>
            </h:dataTable>
         </h:form>
    </f:view>How to identify the row to process in action methed "uebersicht.start"?
    Regards,
    ak

    the easiest way is you can send the parameters for the command link and the
    output link.this parameters will be the unique id of the rows ur r populating .
    get those parameters by:
    request.getParameter(keep the id u kept in the parameters list);
    I worked it out before ,its perfect.
    regards,
    raju reddy

  • Accessing variable of a datatable from Java Code

    Hello,
    I am trying to present a list of objects with a jsf datatable. However, each object needs to be rendered differently, so, I am including another JSP fragment, depending on the datatype.
    JSP code follows:
    <h:dataTable value="#{pc_ConsultaCliente.dadosCliente.historicoCliente}" var="varhistoricoCliente" styleClass="dataTable" >
    <h:column>
    <f:facet name="header">
    <h:outputText styleClass="outputText" value="HistoricoCliente"/>
    </f:facet>
    <%
    String toinclude="";
    try {
    toinclude=FragmentsHandler.getFragmentForBinding(
    javax.faces.context.FacesContext.getCurrentInstance(),
    "#{varhistoricoCliente}" ,
    Contacto.class);
    } catch (Exception ex) { throw new RuntimeException(ex); }
    %>
    <h:panelGroup>
         <jsp:include page="<%= toinclude %>"/>
    </h:panelGroup>
    </h:column></h:dataTable>
    The problem is, when I try to access the varhistoricoCliente from the FragmentsHandler class, I simply can't reach it (I keep on getting null):
    In it, I use (I get fc as a Faces Context from the JSP):
    public static String getFragmentForBinding(FacesContext fc, String valueBinding, Class defaultClass) throws IOException {
    Object o=fc.getApplication().createValueBinding(valueBinding).getValue(fc), defaultClass);
    //After this, o just gets null
    Is this this right? How can I access the var from the datatable component?
    Many thanks!

    I'm no JSF expert but I'm not sure your approach can work at all.
    I would simplify everything by entering a different tag for each different type of object, and enabling the right one with the "rendered" attribute.
    Something like:
    <table>
       <column>
         <tag1 rendered="#{myResult.isType1}">...
         <tag2 rendered="#{myResult.isType2}">...
       ...

Maybe you are looking for

  • Obiee 11g 11.1.1.6 Action links not taking into consideration DashBoard Prompts

    I really hope someone can help. I have a dashboard with an analysis that has a column that is not shown but is prompted via dashboard prompts. This dashboard is a summary set of data and the column in question is deliberately exclude at the request o

  • Quicktime 7.5.5 and mac mini

    After installing Quicktime 7.5.5 on my Mac Mini and restart, Quicktime is still 7.5. Itunes dosn't work. How to solve this problem? I have OS X 10.5.

  • Crystal Reports XIR2のODBC接続について

    以下に関して.何か情報や対応策等ご存知でしたら教えてください. OS:windows server 2003 R2(SP2) 言語:Visual Basic 6.0(SP6) 帳票:Crystal Reports XIR2(SP5) DB:Oracle 9i(9.2.0.8) VB上で以下のコードで記述し.Oracleと接続し.帳票を出力します.     Dim connectproperty As CRAXDRT.ConnectionProperty     For Llidx = 1 To

  • Samsung S5 Issue (Can't Receive Phone Calls)

    Hi everyone! I'm a bit new here but I just recently been having issues with my phone. After the recent update (the one that changed something from OC4 to OF2), my phone cant accept phone calls nor have the ability to make a phone call. My phone can s

  • N95 Only updating recurring calendar items from Ou...

    I am using version 7 PC suite and Outlook 2003 Recently when syncronising it only updates recurring calandar items and not normal appointments into the phone. Can anyone help, Thanks