Struts 2 Type conversion

2009-03-25 Thread mahanare

Hi, I need help in resolving type conversion issue in struts 2.

Here is my problem definition.

I have a structs 2 action class called AuditTrailAction.
Here is the class definition. It contains a ListAuditView I have given my
AuditView bean definition below.

Action contains a List which intern contains a bean containing a Map of
another bean. 

I need to display this data into a tabular structure in jsp page. 

ListAuditView, each AuditView bean contains MapAuditproperty and
AuditProperty bean contains couple of properties.

for each AuditView bean in the list, I need to iterate through all the
AuditProperty beans and display their properties into a row (html table
row).

I have been spending time whole day today with no luck. it looks like there
is some type conversion issue here. I went through
http://struts.apache.org/2.x/docs/type-conversion.html, but not getting a
solution for my scenario which looks little complex. 

Please help me!
Thanks
harinath



public class AuditTrailAction extends ActionSupport implements RequestAware
{
private ListAuditView results;
private int pageSize = 20;
private int page;
private AuditLogDao auditLog;
private Map request;
private String entity;
private String pk;
private ListString columnLabels;

public ListString getColumnLabels() {
return columnLabels;
}

public void setColumnLabels(ListString columnLabels) {
this.columnLabels = columnLabels;
}

public int getPage() {
return page;
}

public void setPage(int page) {
this.page = page;
}

public String getEntity() {
return entity;
}

public void setEntity(String entity) {
this.entity = entity;
}

public String getPk() {
return pk;
}

public void setPk(String pk) {
this.pk = pk;
}

public void setAuditLog(AuditLogDao auditLog) {
this.auditLog = auditLog;
}

public ListAuditView getResults() {
return results;
}

public void setResults(ListAuditView results) {
this.results = results;
}

public String execute() {

try {
results = auditLog.getAuditTrialView(page, pageSize, 
entity, pk);
columnLabels = new ArrayListString();

if (results != null  results.size() != 0) {
AuditView view = results.get(0);
MapString, AuditProperty mapProperties = 
view.getPropertyList();
SetString properties = mapProperties.keySet();
for (String prop : properties) {
columnLabels.add(prop);
}
}
} catch (AuditException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

/*
 * try {
 * 
 * results =auditLog.getAuditTrialInfo(page, pageSize); //
 * request.put(results, results); } catch (AuditException e) 
{ // TODO
 * Auto-generated catch block e.printStackTrace(); }
 */
return SUCCESS;

}

public void setRequest(MapString, Object request) {
// TODO Auto-generated method stub
this.request = request;
}

}



@SuppressWarnings(serial)
public class AuditView implements Serializable {

private MapString,AuditProperty propertyList;// = new
ArrayListAuditProperty();

public MapString, AuditProperty getPropertyList() {
if(propertyList ==null)
{
propertyList = new HashMapString, AuditProperty();
}
return propertyList;
}

public void setPropertyList(MapString, AuditProperty propertyList) {
this.propertyList = propertyList;
}

}

And AuditProperty bean

 */
@SuppressWarnings(serial)
public class AuditProperty implements Serializable {

private static final Log logger = 
LogFactory.getLog(AuditProperty.class);
private String oldValue;
private String newValue;
private boolean updateFlag;



public boolean isUpdateFlag() {
return updateFlag;
}
public void setUpdateFlag(boolean updateFlag) {
this.updateFlag = updateFlag;
}
public String getOldValue() {   
return oldValue;
  

Re: Pagination with struts 2.x

2009-03-25 Thread mahanare

FYI, 
just recording my experience here.

I looked at displaytag it looks good but if there are some minor changes (it
encodes property names etc so when you post for sort/pagination, setting the
structs 2 action properties is difficult) other wise it looks simple.

Also I looked at jqGrid using jquery, it might take some effort but we
really get flashy UI. Also there is some thing called hdpagination another
taglibrary.

at the end as we have some complex stuff, we decided not to use these
libraries and write code on our own to meet our specific requirements.

Thanks
Harinath


Chris Pratt wrote:
 
 One very popular option is DisplayTag (http://www.displaytag.org/).
   (*Chris*)
 
 On Wed, Mar 18, 2009 at 11:08 PM, mahanare mahan...@gmail.com wrote:
 

 Hi,

 What is the best approach to display database table content page wise
 using
 struts 2?

 We used display tag few years back, but there seems another taglib pager
 taglib.

 Is pager tag lib a better option or is there any inherent support in
 struts
 2 for paging?

 Thanks
 harinath

 --
 View this message in context:
 http://www.nabble.com/Pagination-with-struts-2.x-tp22594233p22594233.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


 
 

-- 
View this message in context: 
http://www.nabble.com/Pagination-with-struts-2.x-tp22594233p22700830.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



Re: did any one sussesfully able to use org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

2009-03-25 Thread mahanare

FYI, here is my web.xml

we use spring with struts 2. define all beans in spring context and map them
in struts2.xml (instead of the class=class_with_paackage we give
class=springbean_id
?xml version=1.0 encoding=UTF-8?

web-app id=starter version=2.4 
 xmlns=http://java.sun.com/xml/ns/j2ee; 
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; 
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;

display-nameStruts 2 - Maven Archetype - Starter/display-name

context-param
param-namecontextConfigLocation/param-name
param-valueclasspath*:applicationContext*.xml/param-value
/context-param

!-- Filters --
filter
filter-nameaction2-cleanup/filter-name
   
filter-classorg.apache.struts2.dispatcher.ActionContextCleanUp/filter-class
/filter
filter
filter-namesitemesh/filter-name
   
filter-classcom.opensymphony.module.sitemesh.filter.PageFilter/filter-class
/filter

filter
filter-nameaction2/filter-name
   
filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-class
/filter
 

filter-mapping
filter-nameaction2-cleanup/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-namesitemesh/filter-name
url-pattern/*/url-pattern
/filter-mapping
filter-mapping
filter-nameaction2/filter-name
url-pattern/*/url-pattern
/filter-mapping

!-- Listeners --
listener
   
listener-classorg.springframework.web.context.ContextLoaderListener/listener-class

/listener
  


!-- Servlets --
servlet
servlet-namedwr/servlet-name
servlet-classuk.ltd.getahead.dwr.DWRServlet/servlet-class
init-param
param-namedebug/param-name
param-valuetrue/param-value
/init-param
/servlet
servlet
servlet-namejspSupportServlet/servlet-name

servlet-classorg.apache.struts2.views.JspSupportServlet/servlet-class
load-on-startup5/load-on-startup
/servlet

servlet-mapping
servlet-namedwr/servlet-name
url-pattern/dwr/*/url-pattern
/servlet-mapping


!-- Welcome file lists --
welcome-file-list
welcome-fileindex.jsp/welcome-file
welcome-filedefault.jsp/welcome-file
welcome-fileindex.html/welcome-file
/welcome-file-list

/web-app




sajidbigler wrote:
 
 Hi Friends,
 
 http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html#TroubleshootingguidemigratingfromStruts2.0.xto2.1.x-ExplicitlysettheincludeParamsattributeonallurltagsto%2522get%2522ifitisnotspecified.
 
 web.xml suggest to change it and 
 ActionMappingParams
 
 Parameters set by the action mapping are not set/not available through
 ParameterAware (This change is only needed when going to 2.1.x (where
 x0))
 
 These are now only available if you use the new interceptor named
 actionMappingParams.
 
 but it gives error like
 
 his is usually caused by using Struts tags without the associated filter.
 Struts tags are only usable when the request has passed through its
 servlet filter, which initializes the Struts dispatcher needed for this
 tag. - [unknown location] :( please help me to know more about it.
 
 
 

-- 
View this message in context: 
http://www.nabble.com/did-any-one-sussesfully-able-to-use-org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter-tp22658665p22700953.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



Re: Struts 2 Type conversion

2009-03-25 Thread mahanare

kind of got a fix.

here is my jsp content.

tr
s:iterator value=columnLabels var=label
ths:property value='label' //th
/s:iterator
/tr
s:iterator value=results var=auditViewBean 

tr
 s:iterator value=propertyList var=auditProperty
  s:set var=keyName value=key/s:set
  s:iterator value=columnLabels var=label1
  
s:if test= %{#label1== #keyName}
tds:property value=value.newValue //td
/s:if
/s:iterator
/s:iterator

/tr
/s:iterator




mahanare wrote:
 
 Hi, I need help in resolving type conversion issue in struts 2.
 
 Here is my problem definition.
 
 I have a structs 2 action class called AuditTrailAction.
 Here is the class definition. It contains a ListAuditView I have given
 my AuditView bean definition below.
 
 Action contains a List which intern contains a bean containing a Map of
 another bean. 
 
 I need to display this data into a tabular structure in jsp page. 
 
 ListAuditView, each AuditView bean contains MapAuditproperty and
 AuditProperty bean contains couple of properties.
 
 for each AuditView bean in the list, I need to iterate through all the
 AuditProperty beans and display their properties into a row (html table
 row).
 
 I have been spending time whole day today with no luck. it looks like
 there is some type conversion issue here. I went through
 http://struts.apache.org/2.x/docs/type-conversion.html, but not getting a
 solution for my scenario which looks little complex. 
 
 Please help me!
 Thanks
 harinath
 
 
 
 public class AuditTrailAction extends ActionSupport implements
 RequestAware {
   private ListAuditView results;
   private int pageSize = 20;
   private int page;
   private AuditLogDao auditLog;
   private Map request;
   private String entity;
   private String pk;
   private ListString columnLabels;
 
   public ListString getColumnLabels() {
   return columnLabels;
   }
 
   public void setColumnLabels(ListString columnLabels) {
   this.columnLabels = columnLabels;
   }
 
   public int getPage() {
   return page;
   }
 
   public void setPage(int page) {
   this.page = page;
   }
 
   public String getEntity() {
   return entity;
   }
 
   public void setEntity(String entity) {
   this.entity = entity;
   }
 
   public String getPk() {
   return pk;
   }
 
   public void setPk(String pk) {
   this.pk = pk;
   }
 
   public void setAuditLog(AuditLogDao auditLog) {
   this.auditLog = auditLog;
   }
 
   public ListAuditView getResults() {
   return results;
   }
 
   public void setResults(ListAuditView results) {
   this.results = results;
   }
 
   public String execute() {
   
   try {
   results = auditLog.getAuditTrialView(page, pageSize, 
 entity, pk);
   columnLabels = new ArrayListString();
   
   if (results != null  results.size() != 0) {
   AuditView view = results.get(0);
   MapString, AuditProperty mapProperties = 
 view.getPropertyList();
   SetString properties = mapProperties.keySet();
   for (String prop : properties) {
   columnLabels.add(prop);
   }
   }
   } catch (AuditException e) {
   e.printStackTrace();
   } catch (Exception e) {
   e.printStackTrace();
   }
   
   /*
* try {
* 
* results =auditLog.getAuditTrialInfo(page, pageSize); //
* request.put(results, results); } catch (AuditException e) 
 { // TODO
* Auto-generated catch block e.printStackTrace(); }
*/
   return SUCCESS;
 
   }
 
   public void setRequest(MapString, Object request) {
   // TODO Auto-generated method stub
   this.request = request;
   }
 
 }
 
 
 
 @SuppressWarnings(serial)
 public class AuditView implements Serializable {
   
   private MapString,AuditProperty propertyList;// = new
 ArrayListAuditProperty();
 
   public MapString, AuditProperty getPropertyList() {
   if(propertyList ==null)
   {
   propertyList = new HashMapString, AuditProperty();
   }
   return propertyList;
   }
 
   public void setPropertyList(MapString, AuditProperty propertyList) {
   this.propertyList

Pagination with struts 2.x

2009-03-19 Thread mahanare

Hi,

What is the best approach to display database table content page wise using
struts 2?

We used display tag few years back, but there seems another taglib pager
taglib. 

Is pager tag lib a better option or is there any inherent support in struts
2 for paging?

Thanks
harinath

-- 
View this message in context: 
http://www.nabble.com/Pagination-with-struts-2.x-tp22594233p22594233.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



Problem with convention plugin, trying to load a spring bean as a class object

2009-03-05 Thread mahanare

Hi,

We are facing a problem in a struts2 rest  (2.1.6) application. We have 
configured spring and spring configuration contains the bean definitions for
all rest action classes, While it seem to work, we have the following
problem:

When the rest service action class returns something, it is some how
throwing the following exception.  ironically this exception is thrown while
executing spring bean stakeController. Validate method is called properly
and also create method. 

Could you please advice me on what might be wrong with our project? 

java.lang.RuntimeException: Invalid action class configuration that
references an unknown class named [stakeController]

   
org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:99)
   
org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:379)
   
org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:268)
   
com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
   
com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:214)

-- 
View this message in context: 
http://www.nabble.com/Problem-with-convention-plugin%2C-trying-to-load-a-spring-bean-as-a-class-object-tp22347717p22347717.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



Struts2 rest plugin - making default response to xml

2009-03-04 Thread mahanare

Hi,

I am wondering if it is possible to use default response of the rest action
using rest plugin to xml?

instead of http://domain/orders.xml if i can make it
http://domain/orders as the action for a POST method in a form submssion
and the response should be  xml. Essentially i do not want to have any JSPs
or html files in my web application. It will be a plain rest based services
which process forms and respond with xml.

Thanks in advance

Thanks
harinath

-- 
View this message in context: 
http://www.nabble.com/Struts2-rest-plugin---making-default-response-to-xml-tp22345042p22345042.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



Struts2 rest plugin, spring integration

2009-03-04 Thread mahanare

Hi,

Is there any specific set of instructions to be followed to do the spring
integration with struts2 rest plugin?

Please do let me know.

-- 
View this message in context: 
http://www.nabble.com/Struts2-rest-plugin%2C-spring-integration-tp22346177p22346177.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



Re: Struts2 rest plugin :struts.convention.action.*, possible values

2009-02-20 Thread mahanare

Thanks



 These values, as well as the rest, are documented on the convention 
 plugin page:
 
 http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-Configurationreference
 
 Dave
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Struts2-rest-plugin-%3Astruts.convention.action.*%2C-possible-values-tp22115906p22120182.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



Struts2 rest plugin :struts.convention.action.*, possible values

2009-02-19 Thread mahanare

Hi,

I would like to know where can i get all possible values for structs
constants? 

constant name=struts.convention.action.suffix value=Controller/
constant name=struts.convention.action.mapAllMatches value=true/
constant name=struts.convention.default.parent.package
value=rest-default/



i am evaluating struts 2 rest plugin and want to have some custom handlers.

I would like to know where can i get information on this. I am trying to
figure out this from source code of rest plugin and struts, if you have
inputs, please share with me.

Thanks
Harinath
http;//harinath.in

-- 
View this message in context: 
http://www.nabble.com/Struts2-rest-plugin-%3Astruts.convention.action.*%2C-possible-values-tp22115906p22115906.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