[Struts 2.1.8] Displaying images in a report with the JasperReports plugin

2010-02-07 Thread Celinio Fernandes
Hi,
Using Struts 2.1.8 and the JasperReports plugin for Struts 2 
struts2-jasperreports-plugin-2.1.8.jar.

I am trying to display an image in a PDF report. That image is stored as BLOB 
in the database.

In struts.xml I have specified the following code:

action name=afficheFichePDF 
class=com.eni.dvtejb.clientStruts2.action.JasperArticleAction
    result name=success type=jasper
    param name=locationrapports\ficheArticle.jasper/param
    param name=dataSourceartDetails/param
    param name=formatPDF/param
    param name=reportParametersparamsRapport/param
    param 
name=imageServletUrl/servlets/image?image=/param    
    /result
/action

In my web.xml I have added the mapping for the ImageServlet servlet that is 
part of the JasperReports library :

servlet
    servlet-nameImageServlet/servlet-name
    
servlet-classnet.sf.jasperreports.j2ee.servlets.ImageServlet/servlet-class
  /servlet
  servlet-mapping
    servlet-nameImageServlet/servlet-name
    url-pattern/servlets/image/url-pattern
  /servlet-mapping
  
In my .jrxml file, produced with iReport, I have defined a field with 
Expression class equal to java.io.InputStream.


I get the following error :

Struts Problem Report

Struts has detected an unhandled exception:
Messages:     

   1. Cannot cast object 
'org.apache.struts2.views.jasperreports.valuestackdatasou...@a0d16c' with class 
'org.apache.struts2.views.jasperreports.ValueStackDataSource' to class 
'java.io.InputStream'
   2. Error evaluating expression : Source text : $F{image}
   3. Error evaluating expression : Source text : $F{image}

File:     
org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
Line number:     340
Stacktraces
javax.servlet.ServletException: Error evaluating expression : Source text : 
$F{image}

    
org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:331)
    
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
    
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)

I tried without the image, it works. But then how exactly do you handle images 
with that plugin ? What is the format of the image supposed to be in the .jrxml 
file ?

Thanks for helping.


  

Issues adding i18n Chinese support to existing Struts based code

2010-02-07 Thread Brian Fed
I started working a new assignment of Struts based maintenance J2EE project.
I am new to Struts and having some trouble understanding the code and I seek
Struts expers help here .

Basically we need to add Internationalization support to the existing Struts
based code and here I am trying to show Japanese characters in the browser.



my jsp code looks like below:
--


%@ taglib uri=/WEB-INF/tld/globaltech-formatter.tld prefix=fmt %
...
div class=tabBody
table class=impact2form cellpadding=0 cellspacing=2
tr class=tableRowOdd
td  colspan = 2bean:message bundle=customer
key=customer.calcs.payoff//td
/tr
tr
thfmt:message bundle=customer metaDataRef=loanAmount//th
tdhtml:text property=loanAmount maxlength=10 size=10 tabindex=10
//td
/tr








globaltech-formatter.tld
-


tag
namemessage/name
tagclasscom.globaltech.web.taglib.message.MessageTag/tagclass
bodycontentempty/bodycontent
attribute
namearg0/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namearg1/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namearg2/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namearg3/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namearg4/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namebundle/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namekey/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namelocale/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namename/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
nameproperty/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namescope/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
attribute
namemetaDataRef/name
requiredfalse/required
rtexprvaluetrue/rtexprvalue
/attribute
/tag
...
...





struts-customer.xml
-

?xml version=1.0 encoding=ISO-8859-1?
!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts
Configuration 1.1//EN
  http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd;

struts-config
.
.
message-resources key=customer
 parameter=com.globaltech.customer.CustomerResources/
   
/struts-config





What I did ?
---

1.
I started creating a new file using the Notepad editor on Windows XP . The
file is then saved as type Unicode Big Endian
Next, using the native2ascii utility from JDK 1.4 SDK, I use the following
command to convert this file to an ASCII file:
native2ascii -encoding UnicodeBig CustomerResources_zh.ucd
CustomerResources_zh.properties
The resulting output CustomerResources_zh.properties contains the required
escape code.
I am using this file CustomerResources_zh.properties in my web project.

2.
In my internet explorer, Tools -- Internet Options -- Languages tab, I
added the language Chinese (Hong Kong S.A.R.) [zh-HK]


3.
When I fire a request to my jsp, I see garbage character in my browser
instead of chinese characters.
I tried to even add this line
%@ page contentType=text/html; charset=utf-8 %
to top of my jsp file but still no use.






Can you please clarify what I am missing here and how to add i18n support
for Chinese locale to my existing Struts based code ?


Validation of indexed properties

2010-02-07 Thread hugh111111

I've got a problem relating to the validation of indexed properties in Struts
1.1
I get the following error message when I try to access an ArrayList of
students in my DynaValidatorForm

root cause 

java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
java.util.ArrayList.RangeCheck(Unknown Source)
java.util.ArrayList.get(Unknown Source)
org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298)



Here is some background to the problem...

In my session I have an ArrayList called studentsList of objects of type
experiment.mybeans.Student. A Student object has getter and setter methods
for id, year and gradeAverage.

In my students.jsp I create a table by iterating through my student objects
like this...

c:forEach var=students items=${sessionScope.group.studentsList} 
  trtdhtml:text indexed=true name=students property=id//td
  tdhtml:text indexed=true name=students property=year//td
  tdhtml:text indexed=true name=students
property=gradeAverage//td/tr
/c:forEach

As you can see the table contains empty text boxes and I would like to
validate these have been filled in, so in struts-config.xml I create my
dynavalidatorform as follows...

form-bean name=studentsForm
type=org.apache.struts.validator.DynaValidatorForm 
form-property name=students type=java.util.ArrayList /
/form-bean

And in validation.xml I place my validation rules...

form name=studentsForm 
   field property=id indexedListProperty=students depends=required
 arg0 key=error.studentid.required/
/field
   field property=year indexedListProperty=students depends=required
 arg0 key=error.studentyear.required/
/field
   field  property=gradeAverage indexedListProperty=students
depends=required
 arg0 key=error.studentgrade.required/
/field
/form

Now here is where things start to go a bit pear-shaped

I have read somewhere online that I need to populate the form ArrayList
before I get to my jsp page. So I have created an action class called
PreStudentsAction.java which takes the student ArrayList out of the session
and assigns it to the student ArrayList in the form before forwarding to the
students.jsp page...

public class PreStudentsAction extends Action{

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
 throws Exception
{

DynaValidatorForm myForm = (DynaValidatorForm)form;
Group group = (Group)request.getSession().getAttribute(group);
ArrayListStudent students = group.getStudentsList();

myForm.set(students, students);   
return (mapping.findForward(success));
}

}


Finally when I run my application my table is displayed but when I fill in
the table and press submit I get the IndexOutOfBounds error. It appears to
me that the student ArrayList in the form remains empty and that my Action
class was unsuccessful in populating the form's ArrayList.

Can anybody see what I'm doing wrong?



-- 
View this message in context: 
http://old.nabble.com/Validation-of-indexed-properties-tp27493794p27493794.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org