You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 4 Members of 12451 |
| Forum: Seam Users |
06. Aug 2008, 20:42 America/New_York | Link |
Is there any tag library that works with seam to export a rich:dataTable into a pdf or excel directly? Something like jsp display tag
52 Replies: | |||
|---|---|---|---|
1) i downloaded your seam-excel jar, jxl jar. 2) my page is as follows <h:form id="searchForm">
<a4j:outputPanel id="searchResults">
<h:panelGrid styelClass="panelLayout">
<rich:dataTable id="searchResultsTable" rows="10"
columnClasses="col" value="#{fundsQuery.resultList}" var="fund"
sortMode="single" rowKeyVar="row">
<!-- removed for brevity -->
<rich:column>
</rich:column>
</rich:dataTable>
<h:commandLink value="Export"
action="#{org.jboss.seam.excel.excelExporter.export('searchForm:searchResultsTable')}"/>
</h:panelGrid>
</a4j:outputPanel>
</h:form>
On click of export, I get the following error 18:13:39,187 INFO [STDOUT] H: null 18:13:39,187 INFO [STDOUT] V: null 18:13:39,187 WARN [JXLTemplates] Could not find cell template global, try 18:13:39,187 WARN [JXLTemplates] Could not find cell template data, try 18:13:39,187 WARN [JXLTemplates] Could not find cell template global, try 18:13:39,187 WARN [JXLTemplates] Could not find cell template data, try 18:13:39,187 WARN [JXLTemplates] Could not find cell template global, try 18:13:39,187 WARN [JXLTemplates] Could not find cell template data, try ... ... <same message 200 times>
and ie popup says Any hints? www.reverttoconsole.com |
|||
Ignore the warning, it's a bug. It looks like it can't hook up to the document store that serves the document. What is the URL it can't find? EAR or WAR deployment? What jboss-seam-* libraries do you include and where? Anything extra in components.xml? If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
Priya M : Try using an ordinary h:dataTable and see if that works. I'm not entirely sure rich:dataTable will work... |
|||
Should work. Catfight! If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
Cool. I just haven't found the parsing of the UIColumnGroup and UISubTable :-) |
|||
I'll open a feature JIRA and assign it to you. You can put the code in org.jboss.seam.excel.export.kitchensink. ;-) If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I have just tried something similar to what you have above, and it works. If you see any immediate differences, please post them. xhtml
<h:form id="excelExport">
<a4j:commandButton value="Search" reRender="searchResults" action="#{excelTest.search}" />
<a4j:commandButton value="Clear" reRender="searchResults" action="#{excelTest.clear}" />
<a4j:outputPanel id="searchResults">
<rich:dataTable value="#{excelTest.result}" var="person" id="excelTable" columnClasses="left, right">
<rich:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{person.name} #{person.lastName}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">Age</f:facet>
<h:outputText value="#{person.age}"></h:outputText>
</rich:column>
</rich:dataTable>
<h:commandLink value="Export table" action="#{org.jboss.seam.excel.excelExporter.export('excelExport:excelTable')}" />
</a4j:outputPanel>
</h:form>
javabean
@Name("excelTest")
@Scope(ScopeType.SESSION)
public class ExcelTest
{
private List<Person> people = new LinkedList<Person>();
public List<Person> getPeople()
{
List<Person> ret = new LinkedList<Person>();
for (int i = 0; i < 10; i++)
{
ret.add(new Person(i, "Janne_" + i, "Andersson" + i));
}
return ret;
}
public List<Person> getResult()
{
return people;
}
public void search() {
this.people = getPeople();
}
public void clear() {
this.people = new LinkedList<Person>();
}
}
|
|||
I didn't test it in all browsers. The code works in firefox (3.x) but not in IE 6 or IE 7. Now this really sucks. I'm wondering -- has this anything to do my app being SS: (https) as IE behaves differently for secure sites www.reverttoconsole.com |
|||
When you get the 404, is the URL http:// or https://? If http://, what happens if you manually change it to https:// in the browser? If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I dont see any relevance to your questions and the problem in hand. Perhaps you could suggest what could probably be wrong, since you wrote the code. As for my webapp, I've restricted access to http (even if user access http, port 8080), it redirects to https, port 8443 www.reverttoconsole.com |
|||
AS mentioned earlier, the code does work in firefox. I think you have an incredible component being developed for Seam 2.1. Just need to get the fine details sorted out with browser compatibilities www.reverttoconsole.com |
|||
The generated excel data is presented by a redirect to a DocumentStore (same one which is used by pdf generation). I'm trying to determine if something goes wrong in the redirect. If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
could that behave differently in different browsers? www.reverttoconsole.com |
|||
Not impossible. The 404 indicates that a page is not found. The same redirect that goes to the correct place in another browser apparently. But in order to do the redirect correctly it would be nice to know what goes wrong. Is the 404 on wrong protocol, wrong port or what? If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I haven't mentioned it to be a www.reverttoconsole.com |
|||
Priya M wrote on Aug 07, 2008 22:57:
OK, my bad, I thought it was some
Anyways, tried it under IE7 on https on 8443 and it worked for me so I'll have to ask you to file a JIRA under the excel module with xhtml/bean code and as much info on browser, AS, AS conf, JRE etc as possible. Could be some IE security If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I got this working. It wasn't a problem with Seam's code (although it should be carefully underlined as a note somewhere in the docs). The security constraints used in Internet explorer is quite different from that of Firefox, Safari and even the latest Google Chrome (yes, the reports work well with Google Chrome as it's using Apple's Webkit). Here's what I found after reading a bit about restricting access to clipboards in IE. Read here also. My webapp has security constraints ON as follows <security-constraint> <display-name>Restrict raw XHTML Documents</display-name> <web-resource-collection> <web-resource-name>Security Resource</web-resource-name> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> As you see above, everything was restricted outside of WEB-INF. Now, I'm guessing that the excel generator was generating on the clipboard or temp file on the root and the constraint was not allowing it. I was getting these errors from IE Microsoft excel cannot access the file "https:// " There are several possible reasons The file name or path does not exist The file is being used by another program The workbook you are trying to save has the same name as a currently open workbook I changed the restriction to <url-pattern>*.xhtml</url-pattern> <url-pattern>*.css</url-pattern> <url-pattern>*.img</url-pattern> and now, it works like a charm. Note to Nicklas Karlsson -- You might want to add this in the reference doc. www.reverttoconsole.com |
|||
Thanks for the investigation. I added it to the documention. I'll move it to a Common Issues section once I get a more clear picture of what the common issues in general are. If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I am new to seam and I am trying to export search results to excel, I followed the instruction set in this post, and when I export to excel the excel sheet is not getting all of the data in the result list. It should be getting two columns each with a column header, instead it gets this:
Role Name Select Select Select Select Select Select Role Name should have "Roles" under it and the column with all the Selects should have "Action" as the header. Here is the xhtml that I am using: <h:form id="excelExport"> <h:outputText value="The RBAC Roles search returned no results." rendered="#{empty rbacRolesList.resultList}"/> <rich:dataTable id="rbacRolesList" var="rbacRoles" value="#{rbacRolesList.resultList}" rendered="#{not empty rbacRolesList.resultList}"> <h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="Role Name #{rbacRolesList.order=='rolename asc' ? messages.down : ( rbacRolesList.order=='rolename desc' ? messages.up : '' )}"> <f:param name="order" value="#{rbacRolesList.order=='rolename asc' ? 'rolename desc' : 'rolename asc'}"/> </s:link> </f:facet> #{rbacRoles.rolename} </h:column> <h:column> <f:facet name="header">Action</f:facet> <s:link view="/#{empty from ? 'RbacRoles' : from}.xhtml" value="Select" id="rbacRoles"> <f:param name="rbacRolesRolename" value="#{rbacRoles.rolename}"/> </s:link> </h:column> </rich:dataTable> <h:commandLink value="Export table" action="#{org.jboss.seam.excel.excelExporter.export('excelExport:rbacRolesList')}" /> </h:form> |
|||
So does that mean that I there is no way for me to accomplish this? Or is there a workaround? Thanks. |
|||
This is not the same subject, but I am also stuck on a drop down menu. I am trying to populate a drop down with data from a database table.
When I use this: <h:selectOneMenu id="rolename" styleClass="text" value="#{rbacRolesList.rbacRoles.rolename}"> <s:selectItems value="#{roleNameList.resultList}" var="roleName" label="#{roleName.description}"noSelectionLabel="None"/> </h:selectOneMenu> I get just the "None" in the drop down box. Any ideas? Or could you point me in the right direction? Thanks. |
|||
Daniel, that still did not work. I got the same result as before.
You mean just the s:link within the h:column tag correct? |
|||
Daniel,
How would this be reformatted to work with the export using h:outputText: <h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="Role Name #{rbacRolesList.order=='rolename asc' ? messages.down : ( rbacRolesList.order=='rolename desc' ? messages.up : '' )}"> <f:param name="order" value="#{rbacRolesList.order=='rolename asc' ? 'rolename desc' : 'rolename asc'}"/> </s:link> </f:facet> #{rbacRoles.rolename} </h:column> Thanks for the help. |
|||
<h:column>
<f:facet name="header">
<h:outputText value="text you want">
<a:support event="onclick" reRender="thisContainersId">
additional actionparam if needed to send to bean
</a:support>
</h:outputText>
</f:facet>
<h:outputText value="someValue"/>
</h:column>
|
|||
We are currently on Seam 2.0, with no current plans to move to 2.1 on the radar. Any chance of my getting the source for the 2.x compatible version? |
|||
Ted: The 2.0 code posted in the beginning of this thread is sort of out of date. Nicklas har made major improvements since then, as well as bug fixes. It's not that hard to make the current trunk code (2.1.X) compatible with Seam 2.0. What you need to do is 1) Check out (from svn) or download the Excel module source 2) Copy the DocumentDataStore(?) from the pdf-2.0-src to the excel module src. It is really not that problematic.
3) Maybe do some small If many people request this (there have been 2 so far) I might do it myself, if I get the time. But this will be incredible unsupported. |
|||
Thanks, Daniel. I'll try it. Where's the best place to download Seam 2.1 Excel module source? |
|||
I've downloaded the source as posted, but in comparing the source to the class files in the jboss-seam-excel-20080730.jar, I noticed that there are some classfiles that don't have corresponding source files in the source. Can I safely ignore them? They are: Template.class Validation.class (plus an inner class for each of these) Thanks, Ted |
|||
There has been a lot of changes. Take the 2.1 source and drop the entire excel package into the 2.0 source tree in the same place and fix the DocumentStore... If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
Thanks, Niklas. I've got one error, in UIWorkbook (line 331): The method setFilename(String) is undefined for the type DocumentData. Should I create a setter on DocumentData that just sets the basename, or should I just comment out that line in UIWorkbook? |
|||
Comment it out. If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
I have placed the excel 2.1 source code in 2.0, and have fixed the DocumentStore pdf references. I have also defined the DocumentStoreServlet in web.xml. Additionally, I have added necessary component entries to faces-config, and have added the seam-excel.taglib.xml file to the project. However, when I go to my xhtml page that worked with the seam-excel-20080730.jar, I just get a blank page in the browser. I am not hitting the DocumentStoreServlet for some reason. Everything compiles fine. I know this isn't something you want to support long term, but if you can think of any other configuration I may have missed, I'd appreciate it. |
|||
Stick some debugging in UIWorkbook.encodeEnd to see if it gets that far and where it's trying to go... I'm not sure you need to put the DSS in web.xml for default cases (could that be the problem?) If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
Nope. not even getting to encodeEnd. I wonder--do I need to add a lifecycle reference to DocumentStorePhaseListener to my faces-config, like the pdf-2.0 facesConfig has? |
|||
Does it even make it to the encodeBegin? Compare the JAR contents with the old one attached to the JIRA. If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
So, I've finally gotten it to hit encodeEnd (had to set up my existing facesConfig properly to recognize the excel tags)--here's what I've got so far:
I have an s:link on a page calling |
|||
What is your url pattern in the document store servlet? (web.xml) It looks like you haven't got *.xls in there. |
|||
Thanks Daniel! That was it!! But explain something to me, just 'cause I'm curious: the Jira jar file from July worked with no web.xml tweaking on my part. Why? |
|||
I have no idea :-) It would be cool if you posted a blog or eqiv with the 2.0.X-working jar. Some people probably would be very happy |
|||
My summary would be
The alias is defined somewhere(tm) on higher level, can't remember where. If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
hi, i am using following jarfiles for excel export web application: jboss-seam2.1 1)jboss-seam-excel.jar 2)jboss-seam.jar 3)jboss-seam-ui.jar 4)jboss-el.jar richfaces-3.2.1 1)richfaces-api-3.2.1.GA.jar 2)richfaces-impl-3.2.1.GA.jar 3)richfaces-ui-3.2.1.GA.jar But i am getting following error: Error logs: The class 'org.jboss.seam.Namespace' does not have the property 'excelExporter' Could you please provide me the help on this issue? how to resolve this,... what jar files i need to use? and special setting on need to made on web.xml?? |
|||
Look in the other thread where you asked the same question. |
|||
hi nicklas
i was new to seam, i want to convert an excel (*.xls) file to xml file. Can you please guide me with the necessary libraries how can i do this? Thanks in advance for your greate help sathish |
|||
Not really a seam question but
If a man speaks in the forest and there is no woman around to hear him, is he still wrong? |
|||
What about export to PDF without use <p:...>. Similar to
org.jboss.seam.excel.excelExporter.export(...) ? |
|||
I am new to seam and have a similar functionality described in the thread. I am trying to create an excel out of rich:datable. I did add 1. seam-excel.jar, jxl.jar into my lib path. 2. Added DocumentStoreServlet in the web.xml 3. Added the code similar to below in the jsp. <h:commandLink value="Export" action="#{org.jboss.seam.excel.excelExporter.export('searchForm:searchResultsTable')}"/>
When I execute, I receive the following error The function export must be used with a prefix when a default namespace is not specified. I even defined the default namespace as <html xmlns=""http://jboss.com/products/seam/excel"> I feel like I am missing something critical and simple. Can you please help me. Are there any steps documented some where , if not can you please put them here, which will guide me in achieving the functinality |
|||
any one worked with PDF Export similar way ? please add it in the post, that would help lots of developers.. including me thanks |
|||
Here we go...... the PDF Export Create a file named exportPdf.xhtml use below code <p:document type="PDF" xmlns:p="http://jboss.com/products/seam/pdf"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<p:table columns="4" headerRows="1" widthPercentage="95"
spacingBefore="10">
<p:cell backgroundColor="#EEEEEE">File Index</p:cell>
<p:cell backgroundColor="#EEEEEE">File Name</p:cell>
<p:cell backgroundColor="#EEEEEE">File Size</p:cell>
<p:cell backgroundColor="#EEEEEE">File Date</p:cell>
<ui:repeat var="fileBean" value="#{mediationBeanHome.beanList}"
varStatus="inx">
<p:cell>
<p:text value="#{fileBean.id+1}" />
</p:cell>
<p:cell>
<p:text value="#{fileBean.fileName}" />
</p:cell>
<p:cell>
<p:text value="#{fileBean.fileSize/1000} Kb" />
</p:cell>
<p:cell>
<p:text value="#{fileBean.fileDate}" />
</p:cell>
</ui:repeat>
</p:table>
</p:document>
use the below code as export PDF link <h:commandLink target="#" action="/exportPdf.seam" rendered="#{not empty mediationBeanHome.beanList}" >
<h:graphicImage alt="Export XLS" url="/img/pdf.gif" title="Export table to PDF"/>
</h:commandLink>
Think this might work for all u guys Thanks |
www.reverttoconsole.com