Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
530
dynamically creating an editable grid
posted

Hi

 I am creating a gridView dynamically as result may have different columns for different queries etc. Displaying the columns is working along with rows. But now I need to enable the editing in the gridView.

 resultGridView=new HtmlGridView();

resultGridView.setDataSource(new ListDataModel(investments));

I have found getGridEditing() and it has some enabling methods. But some of them are using string which I believe are defined somewhere to show what are the valid values but api documentation doesn't point to it.

 The bigger issue is that it returns null and there is no setGridEditing() method.

 

  • 165
    posted

      Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

    Hello all,

     

       This is my first post so please be gentle.  I don't even know if this is the correct place to put this, but these other posts are dealing with some of the same issues that I'm having.  What I'm trying to do is have a page with two tabs and within each tab is an editable grid.  The JSP is below.   I get

    org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id0:dataTabs:dataTwoGV:ge2

     found in view. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)

    etc....

      even though I was carful to make sure each of the components have  a uniq ID.  Could it be that I need multiple <f:view> tags???  I'm new to the JSF and Infragistics areana.

     

    This is all leading up to the point where eventually I'm going to dynamically make columns in Java put them into the grid and make the grid editable...  But baby steps first I guess :o)

     

    Any help/advice would be greatly appreciated!

     

    Thanks in advance!!!

     

    Eric Bieche

    Senior Programmer

    Nielsen

     

    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <%@ taglib uri="http://es.infragistics.com/faces/netadvantage" prefix="ig" %>

    <%@ page language="java"

             contentType="text/html; charset=ISO-8859-1"

             pageEncoding="ISO-8859-1" %>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <html>

    <head>

       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

       <link rel='stylesheet' type='text/css' href='style2.css' />

       <title>ABS Penetration Model</title>

    </head>

    <body><f:view><h:form>

       <span class='heading'>ABS Penetration Model</span>

       <br/>

       <ig:tabView id="dataTabs" >

          <ig:tabItem value="Look at Data1">

             <ig:gridView id="dataOneGV"

                          allowFixedColumns="true"

                          rowFetchSize="300"

                          loadOnDemand="default"

                          columnStyleClass="font-style: normal; font-family: Arial, Verdana, Sans-Serif;"

                          style="height: 200px; width: 100%; font-style: normal; font-family: Arial, Verdana, Sans-Serif; font-weight: bold;"

                          binding="#{webgrid_dynamicGridPage.grid1}"

                          dataSource="#{webgrid_dynamicGridPage.data1}" >

     

                <ig:gridEditing id="ge1"

                                enableOnMouseClick="single"

                                cellValueChangeListener="#{webgrid_dynamicGridPage.cellValueChangeListener}" />

     

                <ig:gridActivation id="ga1" />

     

                <f:facet name="header"> <h:outputText value="The Data One" /> </f:facet>

               

                <ig:column style="width:30px" readOnly="true">

                   <f:facet name="header"> <h:outputText value="DMA" /> </f:facet>

                   <h:outputText value="#{DATA_ROW.dmaCode}" />

                </ig:column>

     

    <%-- More columns here --%>

     

                <ig:column style="width:30px">

                   <f:facet name="header"> <h:outputText value="Factor" /> </f:facet>

                   <f:facet name="editor">

                      <h:inputText value="#{DATA_ROW.factor}"

                                   styleClass="igGridCellEdit"

                                   style="width:30px;height:11px" />

                   </f:facet>

                   <h:outputText value="#{DATA_ROW.factor}" />

                </ig:column>

             </ig:gridView>

          </ig:tabItem>

          <ig:tabItem value="Look at Data2">

             <ig:gridView id="dataTwoGV"

                          allowFixedColumns="true"

                          rowFetchSize="300"

                          loadOnDemand="default"

                          columnStyleClass="font-style: normal; font-family: Arial, Verdana, Sans-Serif;"

                          style="height: 200px; width: 100%; font-style: normal; font-family: Arial, Verdana, Sans-Serif; font-weight: bold;"

                          binding="#{webgrid_dynamicGridPage.grid2}"

                          dataSource="#{webgrid_dynamicGridPage.data2}" >

     

                <ig:gridEditing id="ge2"

                                enableOnMouseClick="single"

                                cellValueChangeListener="#{webgrid_dynamicGridPage.cellValueChangeListener}" />

     

                <ig:gridActivation id="ga2" />

     

                <f:facet name="header"> <h:outputText value="The Data Two" /> </f:facet>

     

                <ig:column style="width:30px" readOnly="true">

                   <f:facet name="header"> <h:outputText value="DMA" /> </f:facet>

                   <h:outputText value="#{DATA_ROW.dmaCode}" />

                </ig:column>

     

    <%-- More columns here --%>

     

                <ig:column style="width:30px">

                   <f:facet name="header"> <h:outputText value="Factor" /> </f:facet>

                   <f:facet name="editor">

                      <h:inputText value="#{DATA_ROW.factor}"

                                   styleClass="igGridCellEdit"

                                   style="width:30px;height:11px" />

                   </f:facet>

                   <h:outputText value="#{DATA_ROW.factor}" />

                </ig:column>

             </ig:gridView>

          </ig:tabItem>

    </ig:tabView>

     

    </h:form></f:view></body>

    </html>

  • 1579
    posted in reply to Shahida Fozia

    Hi,

    I was trying to create dynamically a grid and make it editable. The main idea is that you add the gridEditing tag as a child of the gridView tag, i.g.

    <ig:gridView id="grid1" dataSource="#{dynGrid.dataSource}"

    binding="#{dynGrid.grid}"

    pageChangeListener="#{dynGrid.onPageChange}">

    <ig:gridEditing binding="#{dynGrid.gridEditing}"></ig:gridEditing>

    </ig:gridView>

    and bind it to a com.infragistics.faces.grid.component.html.HtmlGridEditing property in the bean. Then I set the following properties

    gridEditing.setEnableOnKeyPress(true);

    gridEditing.setEnableOnF2(true);

    gridEditing.setEnableOnMouseClick("single");

    and added it as a child component of the grid. Unfortuantelly it didn't help either. One possible explanation was that probably the gridEditing tag is being handled only during initialization and the grid cannot be set editable afterwards.

    Regards!

     

  • 530
    posted

    Ok I tried one more thing without any luck: 

    GridEditing gE=
    new GridEditing();

    resultGridView.getFacets().put(HtmlGridView.FACET_EDITOR, gE);

    //Still the following 2 lines get null returned from  resultGridView.getGridEditing().

     resultGridView.getGridEditing().setEnableOnActive(true);

    resultGridView.getGridEditing().setEnableOnMouseClick("single");

    and I also tried just the heck of it:

    HtmlGridEditing gE=new HtmlGridEditing();

    resultGridView.getFacets().put(HtmlGridView.FACET_EDITOR, gE);

    resultGridView.getGridEditing().setEnableOnActive(true);

    same result.