[JBoss Seam] - Re: Generation of jasper reports in seam
by jazir1979
Hi,
I wrote my own JSF component that can view a report inside a div on a given page, and also export a report in a number of output formats. I can't really share the component at this stage, but these snippets should help you get something up and running. Hopefully in the future I can make my component more generic and get permission to contribute it in full.
To view the report, firstly I create the JasperPrint object which is the result of filling the report (JasperFillManager.fillReport()). The following code is inside my customer JSF component and the context variable you see is the FacesContext... however the export gets triggered directly from a Seam action, where you can inject the FacesContext using @In, so you should be able to do this without having to write a JSF component.
| if (jasperPrint != null) {
| final JRExporter exporter = new JRHtmlExporter();
| exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
| exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, context.getResponseWriter());
| exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
| exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
|
| // images
| final HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
| request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
| jasperPrint);
| exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, new HashMap<Object, Object>());
| exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,
| request.getContextPath() + "/jasperimg?image=");
|
| // export
| try {
| context.getResponseWriter().write("<div class=\"reportview\">");
| exporter.exportReport();
| context.getResponseWriter().write("</div>");
| } catch (final JRException e) {
| LOG.error("Report exporting error", e);
| .....
| }
| }
|
To export the report in a whole new response
| final JRExporter exporter = JRExporterFactory.getExporter(outputType, jasperPrint, context);
| final ByteArrayOutputStream stream = new ByteArrayOutputStream();
| exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream);
|
| // export
| try {
| exporter.exportReport();
| } catch (final JRException e) {
| LOG.error("Report exporting error", e);
| ....
| }
| final HttpServletResponse response =
| (HttpServletResponse) context.getExternalContext().getResponse();
| try {
| final OutputStream responseStream = response.getOutputStream();
| response.setContentLength(stream.size());
| response.setContentType(contentTypes.get(outputType));
| if (outputType != ReportOutputType.HTML) {
| response.setHeader("Content-Disposition", "attachment; filename=report." + outputType);
| }
| responseStream.write(stream.toByteArray());
| responseStream.flush();
| responseStream.close();
| response.flushBuffer();
| } catch (final IOException e) {
| LOG.error(e);
| ....
| }
| context.responseComplete();
|
|
I hope this helps you to get it working,
Daniel.
"d.solasa" wrote : Hi
|
| I struck at the point to generate the jasper reports in seam ,ofcourse in jboss too.i even used the component that is given in the jboss site (but that was depricated).And i tried in all the ways that am supposed to generate the jasper reports in java.May be i think i need a jar file or any other configuration to generate jaspe reports in seam..
|
| plz be help me..So urgent that i need to implement it in my project
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047751#4047751
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047751
18 years, 11 months
[JBoss Seam] - process entity from GET request
by nicolasb
hello,
I display Information about an entity with a GET request by using a stateless bean and page parameter in the pages.xml.
on this page which displays a single item i want to execute a conversational bean in which i would like to access the item:
| <h:form>
| <h:inputHidden value="#{item.id}"/>
| <h:commandButton type="submit" action="#{bean.addItem}"/>
| </h:form>
|
doesn't seam to work since as soon as i add the inputHidden Parameter the addItem won't get executed.
the item is somehow loaded into:
| @In
| Item item;
|
because if omit this fragment a exception is thrown regarding the missing input.
it works perfectly fine if i use a different entity. it only breaks as soon as i try to access the entity of the previous GET request
i'm not sure where to continue
thx for any help
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047750#4047750
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047750
18 years, 11 months
[JBossWS] - Unable to start JBoss after installing JBossWS 1.2.1 on JBos
by tejasjani
Hi ,
I tried installing JBossWS 1.2.1 on JBoss 4.0.5 GA (using Java 5), using the following installation instructions:
http://jbws.dyndns.org/mediawiki/index.php/Install_JBossWS
Now, I am unable to start JBoss server which fails with the folllowing exception:
| 2007-05-22 17:17:40,623 WARN [org.jboss.security.auth.login.XMLLoginConfigImpl] End loadConfig, failed to load config: file:/D:/dtsource/main/deploy/servers/jboss-4.0.5.GA1/server/default/conf/login-config.xml
| org.jboss.security.auth.login.ParseException: Encountered "<?xml" at line 1, column 1.
| Was expecting one of:
| <EOF>
| <IDENTIFIER> ...
|
| at org.jboss.security.auth.login.SunConfigParser.generateParseException(SunConfigParser.java:395)
| at org.jboss.security.auth.login.SunConfigParser.jj_consume_token(SunConfigParser.java:333)
| at org.jboss.security.auth.login.SunConfigParser.config(SunConfigParser.java:98)
| at org.jboss.security.auth.login.SunConfigParser.parse(SunConfigParser.java:57)
| at org.jboss.security.auth.login.SunConfigParser.doParse(SunConfigParser.java:79)
| at org.jboss.security.auth.login.XMLLoginConfigImpl.loadSunConfig(XMLLoginConfigImpl.java:310)
| at org.jboss.security.auth.login.XMLLoginConfigImpl.loadConfig(XMLLoginConfigImpl.java:294)
| at org.jboss.security.auth.login.XMLLoginConfigImpl.loadConfig(XMLLoginConfigImpl.java:268)
| at org.jboss.security.auth.login.XMLLoginConfig.startService(XMLLoginConfig.java:176)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy4.start(Unknown Source)
| at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy5.deploy(Unknown Source)
| at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
| at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
| at org.jboss.Main.boot(Main.java:200)
| at org.jboss.Main$1.run(Main.java:490)
| at java.lang.Thread.run(Thread.java:595)
| 2007-05-22 17:17:42,249 INFO [org.jboss.system.server.Server] Runtime shutdown hook called, forceHalt: true
| 2007-05-22 17:17:42,249 INFO [org.jboss.system.server.Server] JBoss SHUTDOWN: Undeploying all packages
|
can anyone pls. help with this
I am assuming that JBossWS 1.2.1 can be run on JBoss 4.0.5 server, although the following line in installation guide makes me suspicious:
anonymous wrote : Currently, we have integration layers for the JBoss application server (> 4.0.5.GA) and Apache Tomcat.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047746#4047746
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047746
18 years, 11 months
[JBoss Seam] - Re: Null pointer rendering mail from @Startup component - se
by javabr
and my @Startup components:
| @Startup(depends="manager")
| @Name("controller")
| @Scope(ScopeType.APPLICATION)
| public class Controller {
|
| @In(create=true)
| private Manager manager;
|
| @Create
| public void create() throws Exception {
| manager.schedule();
| }
| }
|
|
| @Name("manager")
| @Scope(ScopeType.APPLICATION)
| public class Manager {
|
| private static Date MIDNIGHT = null;
|
| @In(create = true)
| Job sendNotificationsToScheduledTasks;
|
| public void schedule() {
| Calendar calendar = GregorianCalendar.getInstance();
| calendar.set(Calendar.HOUR_OF_DAY, 0);
| calendar.set(Calendar.MINUTE, 1);
| calendar.set(Calendar.SECOND, 1);
| MIDNIGHT = calendar.getTime();
| System.out.print(MIDNIGHT);
| sendNotificationsToScheduledTasks.execute(new Date(), Frequency.EVERY_MINUTE.getInterval());
| }
|
| }
|
| package org.bit.etask.scheduler.job;
|
| import java.util.Date;
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.ejb.Timer;
| import javax.persistence.EntityManager;
|
| import org.bit.etask.TaskHelper;
| import org.bit.etask.domain.Task;
| import org.bit.etask.home.ActorHome;
| import org.bit.etask.home.MessageHome;
| import org.bit.etask.home.TaskHome;
| import org.bit.etask.query.TaskList;
| import org.bit.etask.scheduler.Job;
| import org.jboss.seam.annotations.Asynchronous;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Transactional;
| import org.jboss.seam.log.Log;
|
| @Stateless
| @Name("sendNotificationsToScheduledTasks")
| public class SendNotificationsToScheduledTasksBean implements Job {
|
| @In
| Timer timer;
|
| @In
| EntityManager entityManager;
|
| @In(create = true)
| ActorHome actorHome;
|
| @In(create = true)
| TaskHome taskHome;
|
| @In(create = true)
| MessageHome messageHome;
|
| @In(create = true)
| TaskList taskList;
|
| @Logger
| Log log;
|
| @Asynchronous
| @Transactional
| public Timer execute(Date startDate, long interval) {
| log.info("Starting ...");
| List<Task> tasks = taskList.findScheduledTasksToNotifyToday();
| for (Task task : tasks) {
| task.setCurrentActivity(TaskHelper.getLastActivity(task));
| taskHome.setInstance(task);
| messageHome.send();
| }
| log.info("Finished");
| return timer;
| }
|
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047738#4047738
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047738
18 years, 11 months