Re: Struts2 json plugin problem with jpa entity

2011-03-31 Thread Michal Ciasnocha

Hi Massimo,

it might be similar problem with combination JPA and GWT. Read something 
about this on google code 
http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html 
(section Why Hibernate Objects ...). One solution is use own Data 
Transfer Objects.



Regards,

Michal

Massimo Ugues wrote on 31.3.2011 15:34:

Hallo all.
I have a strange issue described here:
http://stackoverflow.com/questions/5497037/struts-json-plugin-problem-serializing-jpa-entity

Any
idea?
Kind regards

Massimo



Re: Struts2 and Validation issue

2011-02-16 Thread Michal Ciasnocha

Hi,

the problem of validation through annotations is they are applied every 
time the action is called. You can try use method which you call from 
your form. For example, if you want to validate only execute method, 
write your own method with name validateExecute(). The principle is same 
for another methods.


I hope this helps.

aum strut wrote on 16.2.2011 15:16:

Hi All,

I am trying to user Validation framework with Struts2 but struck at a
point,here are the details.

I am developing a import service which includes various steps like

1) Showing number of import options

2) Showing number of elgible files for the import (Import type selected in
step one)

for all this i have created only one action with multiple methods which is
doing all the job.now in the second case when user select a file,i am trying
to place a validation for empty field but since property file is outside of
all he methods so the validation is working for all methods

e.g

i do not want the validation to execute for step1  but it is even getting
executed for step one (since file will be selected in step 2 so step1 is
always fails)

is there any way to organise validation so that it should only execute for a
specific method inside the Action

here is my validation code

@RequiredFieldValidator

(type=ValidatorType.*FIELD*,message="Please select a file for import")




*public* String getSelectedFile() {




*return* selectedFile;




}

any help in this regard will be appriciated



Re: Cancel in a form re: bypass Validation

2010-12-09 Thread Michal Ciasnocha

Hi Greg,

I use in my code @SkipValidation annotation for method which I don't 
want to validate. For me it is easier than use interceptors.


@SkipValidation
public String cancel() {
return SUCCESS;
}

The second part - redirect - I hope is correct.


Regards, Michal.

Greg Akins wrote on 9.12.2010 19:46:

I need to have a "Cancel" button on a form that skips the validation
(Struts 2.2.1).  This seems harder than it should be and maybe I'm
missing something.

I've read a few posts about this and ended using the validation
interceptorref to get this to work.

I've had problems getting the interceptorref mechanism to work

@Action(value = "hello-world-cancel",
interceptorRefs = { @InterceptorRef(value = 
"validation", params = {
"excludeMethods", "cancel" })},
results = { @Result(name = SUCCESS, 
location="/jsp/logon.jsp") })
public String cancel() throws Exception {
LOG.debug("Cancelled", "The form has been cancelled");
return SUCCESS;
}

The problem is.. I've got this working as part of the Maven
struts-archetype-starter application.  However, I can't manage to get
the same thing working on my application

Bother are using theme="xhtml".. but my application will only do the
Error Messages and labels if the validate="true" is set on the form.
However, setting the validate=true on the form forces client-side
javascript to be built which is run everytime the form is submitted,
even if it's submitted from the cancel button.

The HelloWorld application looks like it's using serverside validation
(since there isn't any javascript in the page.. but the error messages
and labels still appear).

Any thoughts on what I might be missing?


Re: org.xml.sax.SAXParseException: The content of element type "package" must match

2010-09-02 Thread Michal Ciasnocha

 Check this, it can help you

http://struts.apache.org/2.1.8/docs/strutsxml-examples.html



Satheesh Kannan A B wrote on 2.9.2010 16:50:

Hi,

I think it's a existing and resolved issues in struts 2.1.8, since I have 
googled and searched here but am not able to resolve this.

Currently am configuring interceptors in my struts 2.1.8 application using 
websphere 6.0.1.
What I have coded is right I think so  and u all please verify it and suggest 
me the thing to resolve this.
In the below if I remove the interceptors and global exceptions mapping my 
application working fine.
Am using struts 2.1.8, jdk 6, websphere 6.0.1, xercesImpl-2.8.1

The exception am getting is   give below .
[9/2/10 18:41:56:113 IST] 002c SystemOut O 2010-09-02 18:41:56,082 [WebContainer : 0] ERROR 
com.opensymphony.xwork2.util.DomHelper - The content of element type "package" must match 
"(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)".
 at (null:103:12)
org.xml.sax.SAXParseException: The content of element type "package" must match 
"(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global-results?,global-exception-mappings?,action*)".
   at 
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 
Source)
   at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown 
Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
   at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
   at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
   at com.opensymphony.xwork2.util.DomHelper.parse(DomHelper.java:113)
etc..

and my code wat I have implemented given below 


http://struts.apache.org/dtds/struts-2.0.dtd";>

   
   
   



 
 /search/ldaperror.jsp
 

  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  
   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  

 



 

 
   /html/SessionError.html
 

 /html/SessionError.html

 
 
 

   
   index_kew.jsp
   

   


Thanks  and Regards,

Satheesh Kannan A B


DISCLAIMER:
---

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and
attachments please check them for viruses and defect.

--

Re: I cant load Select Box dynamically

2010-08-27 Thread Michal Ciasnocha

 Basic example:

you have jsp:


   



and your are accessing action CountryAction. In class CountryAction you 
must create getter method for list attibute of select tag. Your list has 
name "countryList". So you need to create getter method

List getCountryList() { return countryList; }

In countryList attribute you must have values which you want to get on 
your page. Your code have populate method - here you get data from 
database and these values are saved into list variable. Why do you have 
this variable named list and not countryList? Method getCountryList() 
returns empty variable. Information which you need are in list variable, 
but you are not accesing it - you getter calls countryList variable. 
Just rename list variable to countryList.


vinodh r wrote on 27.8.2010 12:14:
Hi, Thanks for reply Mr.Michal Ciasnocha... I cant understand i need some explanation, i don't know how to set in a attribute. 
Also I can't copy the result returned from " Data_Conn.load_country() to another list or array list. only chance is to use " Data_Conn.load_country()" as a original.

if you know please do some modification on action page and paste as reply. 
Thanks in advance.
Vinodh .R--- On Fri, 8/27/10, Michal Ciasnocha  wrote:

From: Michal Ciasnocha
Subject: Re: I cant load Select Box dynamically
To: "Struts Users Mailing List"
Date: Friday, August 27, 2010, 3:14 AM

   Hi,

in class CountryAction you need assign retreived values from database to
countryList attribute, not list (you have in jsp ... list="countryList"
...).

vinodh r wrote on 27.8.2010 7:04:

Hi,I cant load Select box dynamically. I am new to struts2, but i can do it 
statically in action page so that it will refelect in jsp page. But what i have 
to do modification in action page so that i get display in jsp page i loaded 
array list dynamically from database. Thanks in advance.

Here is the action
//CountryAction .javapackage com.pac.struts.action;import 
java.sql.SQLException;import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;import com.pac.struts.DataConn.Data_Conn;import 
com.pac.struts.model.Country;public class CountryAction extends ActionSupport{private static final long 
serialVersionUID = 1L;private String country;private ArrayList   countryList;
public ArrayList list;public String populate() throws Exception{list = 
Data_Conn.load_country();return "populate";}public String execute(){
return SUCCESS;}public String getCountry(){return country;}public void 
setCountry(String country){this.country = country;}public ArrayList   
getCountryList(){return countryList;}public void setCountryList(ArrayList   
countryList){this.countryList = countryList;}}


/Data_Conn.java**/package com.pac.struts.DataConn;
import java.sql.Connection;import java.sql.DriverManager;import 
java.sql.ResultSet;import java.sql.SQLException;import 
java.sql.Statement;import java.util.ArrayList;
import com.pac.struts.model.Country;
public class Data_Conn {static Connection con;static Statement st;
 static ResultSet rs;public static void connection_1() throws ClassNotFoundException, SQLException{Class.forName("com.mysql.jdbc.Driver");con = (Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=root");st = con.createStatement();System.out.println("Open Connection Initiated");}public static void close_1() throws SQLException{   
 st.close();con.close();System.out.println("Close Connection Initiated");}public static ArrayList   load_country() throws ClassNotFoundException, SQLException {connection_1();rs = st.executeQuery("select * from test.country_tbl");ArrayList   countryList = null;   
 while(rs.next()){countryList = new ArrayList();countryList.add(new Country(rs.getInt(1), rs.getString(2)));}close_1();System.out.println("List Operation Completed");return countryList;}   
 }

/*Country.java***/package com.pac.struts.model;
public class Country {private int countryId;private String countryName; 
   public Country(int countryId, String countryName){this.countryId 
= countryId;this.countryName = countryName;}

 public int getCountryId() {return countryId;}
 public void setCountryId(int countryId) {this.countryId = 
countryId;}
 public String getCountryName() {return countryName;}
 public void setCountryName(String countryName) {this.countryName = countryName;}   
}


/*countryworld.jsp**/










Re: I cant load Select Box dynamically

2010-08-27 Thread Michal Ciasnocha

 Hi,

in class CountryAction you need assign retreived values from database to 
countryList attribute, not list (you have in jsp ... list="countryList" 
...).


vinodh r wrote on 27.8.2010 7:04:

Hi,I cant load Select box dynamically. I am new to struts2, but i can do it 
statically in action page so that it will refelect in jsp page. But what i have 
to do modification in action page so that i get display in jsp page i loaded 
array list dynamically from database. Thanks in advance.

Here is the action
//CountryAction .javapackage com.pac.struts.action;import 
java.sql.SQLException;import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;import com.pac.struts.DataConn.Data_Conn;import 
com.pac.struts.model.Country;public class CountryAction extends ActionSupport{ private static final 
long serialVersionUID = 1L;private String country; private ArrayList  countryList;  
public ArrayList list;  public String populate() throws Exception{  list = 
Data_Conn.load_country();return "populate";}   public String execute(){   
 return SUCCESS; }   public String getCountry(){ return country; }   public 
void setCountry(String country){ this.country = country; }   public ArrayList  
getCountryList(){  return countryList; }   public void 
setCountryList(ArrayList  countryList){  this.countryList = countryList; }}


/Data_Conn.java**/package com.pac.struts.DataConn;
import java.sql.Connection;import java.sql.DriverManager;import 
java.sql.ResultSet;import java.sql.SQLException;import 
java.sql.Statement;import java.util.ArrayList;
import com.pac.struts.model.Country;
public class Data_Conn {static Connection con;  static Statement st;
static ResultSet rs;public static void connection_1() throws ClassNotFoundException, SQLException{
  Class.forName("com.mysql.jdbc.Driver");   con = 
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=root");
st = con.createStatement(); System.out.println("Open Connection 
Initiated");  }   public static void close_1() throws SQLException{   
st.close(); con.close();System.out.println("Close Connection 
Initiated"); }   public static ArrayList  load_country() throws 
ClassNotFoundException, SQLException {connection_1(); rs = st.executeQuery("select * 
from test.country_tbl");   ArrayList  countryList = null;   
while(rs.next()){   countryList = new ArrayList();   
countryList.add(new Country(rs.getInt(1), rs.getString(2)));}   
close_1();  System.out.println("List Operation Completed");   
return countryList; }   
}
/*Country.java***/package com.pac.struts.model;
public class Country {  private int countryId;  private String countryName; 
public Country(int countryId, String countryName){  
this.countryId = countryId; this.countryName = countryName; }

public int getCountryId() { return countryId;   }
public void setCountryId(int countryId) {   this.countryId 
= countryId; }
public String getCountryName() {return countryName; 
}
public void setCountryName(String countryName) {
this.countryName = countryName; }   
}

/*countryworld.jsp**/






Re: Get i18n text problem

2010-08-09 Thread Michal Ciasnocha

 Hi Franz,

you can use tag  for text 
translation (where "title" is name of your variable).



Best regards,

Michal

Franz Wong wrote on 9.8.2010 5:14:

Hi group,

In the jsp page, I have a page scope variable "title". This variable stores
the key of the resource bundle. I can print the value by<%= title %>.
However, I am not able to use it with.

I have tried  or. But
both of them do not work.

Thanks.
Franz



Re: getting label from property

2010-07-28 Thread Michal Ciasnocha

 Hi Ryan,

for getting translated text as label of select tag (and other tags) use 
"key" attribute. Usage is same as .



Best regards,

Michal

Ryan Beckes wrote on 28.7.2010 20:16:

Hi All,

I'm working my way through properties and I'm kind of stuck. I have a
properties file (package.properties) with a "message" entry...

Index.message= Color

... I am able to pull this message via the s:text tag, so I know it's
available in the value stack, but when I try to pull the same message for
the select label below, it does not work. I've also tried %{message} and
%{getText('message')}.

Thanks,
Ryan


<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

   
 
   
 
 
   
   
   
 
   




Re: Display GregorianCalendar Objects

2010-07-28 Thread Michal Ciasnocha

 In that case you must use own converter like this:

public class DateTimeConverter extends StrutsTypeConverter {

 @Override
 public Object convertFromString(Map context, String[] values, 
Class toClass) {

  try {
   return DateUtil.getConvertedDate(values[0], 
DateUtil.DATE_TIME);

  } catch (TypeConversionException tce) {
   log.error("Exception while parsing date.", tce);
  }
  return null;
 }
}

Method getConvertedDate() just parse inserted date as string by user.

Reeshi Agrawal wrote on 28.7.2010 15:05:

Michal,
I wanted the user to input his birth-date. Displaying the current date will
be of no use for it.



Re: Display GregorianCalendar Objects

2010-07-27 Thread Michal Ciasnocha

 Why don't use Struts tag s:date for date formatting?

in Action:

public GregorianCalendar getMyDate() {
  return new GregorianCalendar();
}

in jsp:



Michal


Hi all,
i do it like that:
in my POJO GregorianCalendar field,
on my jsp text field + jquery calendar.
If You want to create date in some kind of predefined format
You can use Conventer for GregorianCalendar for your app.


Best greetings,
Paweł Wielgus.

2010/7/27 Reeshi Agrawal:

Same problem with me...
I want (through Struts 2 tags), a way to display date as three adjacent
(side-by-side) drop-down menus, one each for date,month and year. Normally
what will happen is: the three drop-down menus will be displayed in three
separate consecutive rows in the HTML table generated in Struts 2. But I
want them to be present in a single row in the displayed HTML table. Do I
need to do some modification in the freeMarker templates' .ftl files? Or is
there another very simple thing that I am missing?
I know I am asking a very simp;e thing, but its bugging me from quite some
time...


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



Re: textfield escapes name attribute

2010-07-24 Thread Michal Ciasnocha

Hi Björn,

I think it is general problem with naming attributes in local languages. 
Best practice for Java (and other programming languages) is use only 
some characters (that means a - z, numbers and underscore).


Why didnt use for attribute "stra*ß*e" its equivalent like "strasse"? It 
saves you much troubles :).


Note: Values are encoded properly because they are values and respect 
your local settings.



Best regards,

Michal

Hi group,

I am having some trouble with the textfield tag. We have java beans that use 
german umlauts as well as the letter 'ß' in some property names. To set the 
property in a from we use the textfield tag. Below is a snippet:


   Straße
   


Problem is the rendered html page escapes the name attribute, which result in a 
null value for the property straße. Same goes for all properties that use umlauts. 
ö becomesö and so on...


Straße



However we can enter umlauts in a input field and have the value properly 
encoded in the property of the bean.


   Ort
   


If we enter 'München' in this input field, we actually recieve 'München' on the 
server.

We use struts2 2.1.8.1 and the javatemplates-plugin. Tomcat  URIEncoding is set 
to UTF-8. Every jsp is encoded with UTF-8 and the headers are properly set.

<%@ page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>


Any ideas?

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