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: | 23 Members of 4546 |
| Forum: Seam Users |
06. Aug 2008, 20:42 CET | 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
46 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? |
|||
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? |
|||
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>();
}
}
|
|||
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 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 |
|||
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 |
|||
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? |
|||
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? |
|||
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? |
|||
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 |
|||
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. |
|||
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? |
|||
Revert To Console