my dog learned polymorphism*
The moose likes JSF and the fly likes Problem with building columns dynamically using dataTable tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem with building columns dynamically using dataTable tag" Watch "Problem with building columns dynamically using dataTable tag" New topic
Author

Problem with building columns dynamically using dataTable tag

jane fridkin
Greenhorn

Joined: Nov 15, 2006
Posts: 6
Problem with building columns dynamically using dataTable tag

Hi everyone!
I need some help to figure out the way of displaying DYNAMIC number of columns in the table.

Here is a snippet on the code I�m using

<h:dataTable value="#{DomainListController.authorizedDomains}" var ="domains" columnClasses="list-column-center,list-column-right, list-column-center,list-column-right">
<h:column>
<h:commandLink action="#{DomainController.selectDomain}">
<h:graphicImage value="#{domains.imageName}" style="border: thin solid black" width="40" height="40"/>
<f:param name="domainId" value="#{domains.domainId}" />
</h:commandLink> <f:verbatim><br></f:verbatim>
<hutputText value="#{domains.description}"/>
</h:column>

</h:dataTable>

Issue with that is that all graphic Images are displayed in one column.

Thanks in advanced for your help!!!
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
jane,

You have only one h:column that's why everything is displayed in one column in different rows.
If you need them to be displayed in different columns across the page, you may refer to t:dataTable of Myfaces. An example is in here. Refer to the link "Dynamic number of columns, add a column " on this page.
Hope this helps.
jane fridkin
Greenhorn

Joined: Nov 15, 2006
Posts: 6
OK, I did download tomahawk.jar(Implementation-Version: 1.1.3) and place it to the WEB-INF\lib directory(i'm running Weblogic 8.1)
Well, now I'm facing different issue: my app has customized faces-config.xml in \WEB-INF dir
Here is a snippet:
<?xml version='1.0' encoding='UTF-8'?>
<!-- Copyright 2004 ArcMind, Inc. All rights reserved.-->
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

AND tomahawk.jar has it's own META-INF\faces-config.xml with dtd/web-facesconfig_1_1.dtd
So here are my questions:
1. How to combine those xml files and should I?
2. Do I need to reference http://www.apache.org/licenses/LICENSE-2.0 somewhere?
3.Do I need to update web.xml?

Thanks a lot for your help!!!
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
Jane,

I am not sure if tomahawk.jar will give its own faces-config.xml.
Its been 3 months only since I started working on JSF. I am not an expert.. yet!!All I did for my project was download the faces-blank.jar from a website and then update the jars with the latest. I should have mentioned that I am using Apache MyFaces and Tomahawk. If you are using any other implementation of JSF like Sun RI, then I am not sure if that implementation has any dynamic column data table components. But if you want to switch to MyFaces, then you need to overwrite the other jars with MyFaces jars.(myfaces-api and myfaces-impl and other commons jars). Make sure that the versions of the jars that you download are compatible with each other. Sufficient documentation is available regarding the compatibility in the Apache website.

Experts,
Please advise.
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
You don't need to combine the faces-config.xml of your application and tomahawk.jar... just make sure the jsf api that you are using and tomahawk.jar are compatible.
You do need to make change to web.xml. You need to configure a filter in web.xml. You can search on the internet for that.
jane fridkin
Greenhorn

Joined: Nov 15, 2006
Posts: 6
Thanks a lot for you reply!
The issue is actually solved.. with JSTL(we wanted to stay with SUN technologies)
That code is working with jstl1.0 under jsp1.2(NOT 2.0) that is weblogic8.1 restrictions
NOTE:!!! For jsf tags to work you have to reassign var="item" to var="id" and make it scope="REQUEST"!!!
Here is a snippet of the code:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<table>
<%
DomainListController domainListController =new DomainListController();
List domains = (List) domainListController.getAuthorizedDomains();
pageContext.setAttribute("domains", domains);
%>
<c:set var="counter" value="0" />
<c:set var="row_number" value="4" />
<c:forEach var="item" items="${domains}">
<c:set var="id" value="${item}" scope="request" />
<c:if test="${counter == 0}">
<tr>
</c:if>
<td width="100" valign="top" align="center">
<h:commandLink action="#{DomainController.selectDomain}">
<h:graphicImage value="#{id.imageName}" style="border: thin solid black" width="40" height="40"/>
<f:param name="domainId" value="#{id.domainId}" />
</h:commandLink>
<hutputText value="#{id.description}"/>
</td>
<c:set var="counter" value="${counter + 1}" />
<c:if test="${counter == row_number}">
<c:set var="counter" value="0" />
</tr>
</c:if>
</c:forEach>
</table>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with building columns dynamically using dataTable tag
 
Similar Threads
how to display list using jsf
Dynamic value for verbatim tag
Loading DB data when web app context initialized
nested h:datatable question
how to retrieve a particular value from datatable