Help

Controls

PermLinkWikiLink

Built with Seam

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.

Forum: Seam Users Forum ListTopic List
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

 

www.reverttoconsole.com

52 Replies:
06. Aug 2008, 21:02 America/New_York | Link

There will be in 2.1

There is a 2.x compatible version that can be found here. Check out the section on datatable export in the docs

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

Rating:  * *
07. Aug 2008, 00:19 America/New_York | Link

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 Cannot open file

Any hints?

 

www.reverttoconsole.com

07. Aug 2008, 07:49 America/New_York | Link

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?

07. Aug 2008, 09:11 America/New_York | Link

Priya M : Try using an ordinary h:dataTable and see if that works. I'm not entirely sure rich:dataTable will work...

07. Aug 2008, 09:20 America/New_York | Link

Should work. Catfight!

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

07. Aug 2008, 09:37 America/New_York | Link

Cool. I just haven't found the parsing of the UIColumnGroup and UISubTable :-)

07. Aug 2008, 09:42 America/New_York | Link

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?

07. Aug 2008, 09:43 America/New_York | Link

Also please try without the ajax-stuff :-)

07. Aug 2008, 10:33 America/New_York | Link

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>();
   }
}
07. Aug 2008, 17:11 America/New_York | Link

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

07. Aug 2008, 21:24 America/New_York | Link

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?

07. Aug 2008, 21:35 America/New_York | Link
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

07. Aug 2008, 21:38 America/New_York | Link

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

07. Aug 2008, 21:42 America/New_York | Link

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?

07. Aug 2008, 21:45 America/New_York | Link

could that behave differently in different browsers?

 

www.reverttoconsole.com

07. Aug 2008, 21:50 America/New_York | Link

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?

07. Aug 2008, 22:57 America/New_York | Link

I haven't mentioned it to be a 404 problem. Why do you ask?

 

www.reverttoconsole.com

08. Aug 2008, 09:24 America/New_York | Link
Priya M wrote on Aug 07, 2008 22:57:
I haven't mentioned it to be a 404 problem. Why do you ask?

OK, my bad, I thought it was some friendly IE http error message since you didn't correct me directly whan I started talking about the 404.

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 feature also, please try setting security as low as possible (allow redirects etc).

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

Rating:  * *
04. Sep 2008, 03:20 America/New_York | Link

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

04. Sep 2008, 09:24 America/New_York | Link

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?

30. Sep 2008, 21:08 America/New_York | Link
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>
30. Sep 2008, 21:32 America/New_York | Link

Related to this. The export looks for children of UIOutput for data (meaning it doesn't see your s:link and inline text. It's high on my priority list...

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

30. Sep 2008, 21:39 America/New_York | Link

So does that mean that I there is no way for me to accomplish this? Or is there a workaround? Thanks.

30. Sep 2008, 21:48 America/New_York | Link

Exchange s:link with h:outputText and it will work :-)

30. Sep 2008, 21:52 America/New_York | Link
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.
30. Sep 2008, 21:56 America/New_York | Link
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?

30. Sep 2008, 22:25 America/New_York | Link
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.
30. Sep 2008, 22:40 America/New_York | Link
<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>
27. Oct 2008, 21:49 America/New_York | Link

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?

27. Oct 2008, 23:19 America/New_York | Link

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 naming fixes. (pdf->excel)

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.

28. Oct 2008, 00:42 America/New_York | Link

Thanks, Daniel. I'll try it. Where's the best place to download Seam 2.1 Excel module source?

28. Oct 2008, 14:33 America/New_York | Link

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

28. Oct 2008, 14:42 America/New_York | Link

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?

28. Oct 2008, 15:46 America/New_York | Link

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?

28. Oct 2008, 16:11 America/New_York | Link

Comment it out.

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

29. Oct 2008, 21:06 America/New_York | Link

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.

30. Oct 2008, 11:25 America/New_York | Link

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?

30. Oct 2008, 15:44 America/New_York | Link

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?

30. Oct 2008, 22:51 America/New_York | Link

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?

31. Oct 2008, 14:43 America/New_York | Link

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 change-set.jsf. I have an xhtml page called change-set.xhtml with a rudimentary set of workbook tags that I want to be in excel spreadsheet form. My pages.xml has an entry for change-set.xhtml that simply defines a param that I'm passing in via my s:link. When I click the link, I get a page not found error. The url at this point is change-set.xls

31. Oct 2008, 15:09 America/New_York | Link

What is your url pattern in the document store servlet? (web.xml) It looks like you haven't got *.xls in there.

31. Oct 2008, 15:29 America/New_York | Link

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?

02. Nov 2008, 21:15 America/New_York | Link

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

02. Nov 2008, 21:45 America/New_York | Link

My summary would be

  1. Don't use explicit DocumentStore in web.xml (that way you don't have to do the *.xls mapping)
  2. Use the full name that is on the ExcelExporter component (packages might have changed)

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?

03. Nov 2008, 11:51 America/New_York | Link

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??

03. Nov 2008, 21:41 America/New_York | Link

Look in the other thread where you asked the same question.

26. Jan 2010, 11:51 America/New_York | Link
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
26. Jan 2010, 12:16 America/New_York | Link

Not really a seam question but

  1. Grab JExcelapi from http://jexcelapi.sourceforge.net/ and read through the docs
  2. Write code that iterates over the data in the xls and outputs to xml (coding left as an exercise for the reader)
 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

24. Feb 2010, 20:33 America/New_York | Link
What about export to PDF without use <p:...>. Similar to

org.jboss.seam.excel.excelExporter.export(...) ?
17. Mar 2010, 15:24 America/New_York | Link

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

01. Mar 2011, 15:38 America/New_York | Link

any one worked with PDF Export similar way ? please add it in the post, that would help lots of developers.. including me

thanks

01. Mar 2011, 16:28 America/New_York | Link

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