wood burning stoves 2.0*
The moose likes JSF and the fly likes JSF 1.2 Facelets - Component ID form1:dataTable:j_id101 has already been found in the view Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 1.2 Facelets - Component ID form1:dataTable:j_id101 has already been found in the view" Watch "JSF 1.2 Facelets - Component ID form1:dataTable:j_id101 has already been found in the view" New topic
Author

JSF 1.2 Facelets - Component ID form1:dataTable:j_id101 has already been found in the view

Solomon Gnanadurai
Greenhorn

Joined: May 20, 2011
Posts: 24
I have links in datatable when clicked calls the backing session bean (CustomerAndAccountInfo) and populate some text fields in the screen to edit the table data.
<h:dataTable binding="#{CustomerAndAccountInfo.dataTable}" id="dataTable" border="1" value="#{CustomerAndAccountInfo.currentService.packageVO}" var="packageList" styleClass="ct02" headerClass="ch02" rowClasses="row1,row2" cellspacing="0">

<h:column>
<f:facet name="header">
<hutputText value="Action Type" />
</f:facet>
<h:inputHidden value="#{packageList.id}"></h:inputHidden>
<h:commandLink action="#{CustomerAndAccountInfo.editDataItem}" styleClass="hiddenlink">
<hutputText value="#{packageList.actionType}" > </hutputText>
</h:commandLink>

</h:column>
In editDataItem() I am able to get the values from datatable but sometimes it throws
Root cause of ServletException. java.lang.IllegalStateException: Component ID form1:dataTable:j_id101 has already been found in the view
I looked around and added the below code in editdataitem() but didn’t fix the issue.
if (dataTable != null) {
UIComponent abc = dataTable.getParent();
abc.getChildren().remove(dataTable);
dataTable=null;
}

I also tried to bind the datatable to PackgeVO but its object is null in the bean editDataItem() method.
I am using JSF1.2 and facelets. Any help would be greatly appreciated. Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

Helpful hint: use our editor's "Code" button to wrap special tags around your sample code and XML. It makes them easier to read.

One of the biggest problems with JSF is that everybody is used to having to do a lot of complicated work to get things done and JSF is designed very much with the idea that you shouldn't have to do a lot of complex work. Or, as Alan Kay once said: "Simple things should be simple and complex things should be possible."

In the case of adding and removing rows from a datatable, that means you don't need to actually go in and meddle with the UI elements, just update the datamodel. When the table is re-rendered, it will reflect the datamodel.

So, assuming a ListDataModel:


To remove the row that was clicked on:



By the way, package name elements ("CustomerAndAccountingInto") should not begin with upper-case letters.


Customer surveys are for companies who didn't pay proper attention to begin with.
Solomon Gnanadurai
Greenhorn

Joined: May 20, 2011
Posts: 24
Hi Tim,

My data model looks like this:



CustomerAndAccountInfo session bean has the property ServiceVO and editDataItem() method like this



As you can see the commented lines I was trying to get the RowData from HtmlDataTable which is working fine but I get exception sometimes: Component ID form1:dataTable:j_id101 has already been found in the view.
And I also tried to cast the List to ListDataModel as above but it throws ClassCastException. I am not sure how to get packageVO.getCurrentRow() and packageVO.getWrappedData() from the List object
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

You cannot use a Java array or Collection object directly as a dataTable model object. You have to wrap it in a JSF DataModel object such as a ListDataModel or ArrayDataModel. That object would be what the value attribute on the dataTable page tag references.

The reason for this is that in addition to holding the data itself, the datamodel also maintains the cursor used to track the rows of the table.

Solomon Gnanadurai
Greenhorn

Joined: May 20, 2011
Posts: 24
Tim, currently I am using the PackageVO list in so many other parts of the code and my datamodel looks like the below. Can you suggest me exactly what code changes I have to make? Thanks
Solomon Gnanadurai
Greenhorn

Joined: May 20, 2011
Posts: 24
Tim, thanks for your suggestion to use ListDataModel. I followed this post on how to use ListDataModel http://numberformat.wordpress.com/2010/08/25/using-jsf-to-display-table-data/ and I have resolved the issue. I will update this thread if I ran across again the intermittent issues I had before. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF 1.2 Facelets - Component ID form1:dataTable:j_id101 has already been found in the view
 
Similar Threads
simulate clicking of edit column command button in data table from another component in data table
Datatable column header issue
Input row select on data table does not get called
commandLink not working in datatable+jsf2.0
Get the count of selectted checkbox