• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

migrate struts1 to struts2 --> meet difficulty

 
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I am migrating from struts1 to struts2 web application.

I find that in struts2, how to implement multiple resources file based on locale and different module. e.g. in previous struts1 version, I have below in struts-config.xml
Moreover, how in implement in controller code in struts2 ?? Please help!!!


based on different module:
<message-resources key="cardResources" parameter="com.aeon.onlineapplications.struts.CardApplicationResources" />
<message-resources key="creditResources" parameter="com.aeon.onlineapplications.struts.CreditApplicationResources" />

And

for each com.aeon.onlineapplications.struts.CardApplicationResources , I have
based on different language:
CardApplicationResources_fr.properties
CardApplicationResources_de.properties
CardApplicationResources_zh.properties
CardApplicationResources.properties

And in struts1 jsp file as below in my case. Does I need to change also for struts2 framework??

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
<BODY TOPMARGIN="0" LEFTMARGIN="0" ONCONTEXTMENU="return false;" onload="ga_send('public', 'CardApp2');">
<CENTER>
<TABLE CELLPADDING="0" CELLSPACING="0">
<TR><TD ALIGN="CENTER"><IMG SRC="<bean:message bundle="cardResources" key="image.card.header" />"></TD></TR>
<TR><TD ALIGN="CENTER"><BR>
<IMG SRC="<bean:message bundle="cardResources" key="image.card.finish" />" USEMAP="#EMAILMAP" />
<MAP NAME="EMAILMAP">
<bean:message bundle="cardResources" key="label.card.finish.imagemap1" />
<bean:message bundle="cardResources" key="label.card.finish.imagemap2" />
</MAP>
</TD></TR>

.................



 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now in struts2 web show below error:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
org/apache/struts/util/MessageResources
java.lang.NoClassDefFoundError: org/apache/struts/util/MessageResources
File: org/apache/struts/taglib/bean/DefineTag.java
Line number: 50
Stacktraces

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/struts/util/MessageResources
   weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
   weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:417)
   weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
   weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
   weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:523)
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my struts2 web project, if I include struts-core.jar, it shows below:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
Cannot find bean: "AeonLoanForm" in any scope
javax.servlet.jsp.JspException: Cannot find bean: "AeonLoanForm" in any scope
File: org/apache/struts/taglib/TagUtils.java
Line number: 864
Stacktraces

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "AeonLoanForm" in any scope
   weblogic.servlet.jsp.PageContextImpl.handlePageException(PageContextImpl.java:417)
   jsp_servlet._web_45_inf._jsp.__aeon_loan_form._jspService(__aeon_loan_form.java:2812)
   weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
   weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My jsp page is like below: I just have the question whether taglib cannot be used in struts2??? for example I cannot code <bean:define id="months" name="AeonLoanForm" property="monthRange" type="java.util.Collection" /> ??? is it??

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ page import="java.util.*" %>
<%@ page import="com.aeon.awip.hibernate.SBranchCat" %>
<%@ page import="com.aeon.awip.hibernate.SBranch" %>

<bean:define id="days" name="AeonLoanForm" property="dayRange" type="java.util.Collection" />
<bean:define id="months" name="AeonLoanForm" property="monthRange" type="java.util.Collection" />
<bean:define id="years" name="AeonLoanForm" property="yearRange" type="java.util.Collection" />
<bean:define id="channelSrc" name="AeonLoanForm" property="channelSrc" type="String"/>
<%
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreover, is it possible to have resource bundle of getText("xxxkeyxxxx") in Controller (include userClass and Action Class)??


 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 2 started life as a completely different framework called WebWork so it doesn't have many "features" of Struts 1 like ActionForms (thank goodness!).  You will not be able to use Struts 1 tags with Struts 2.  Have a look at the migration guide (scroll down to "Struts 1 to Struts 2").  This will probably answer many of your questions.  
As for resource bundles, look at the FAQ entry on Localization.  
reply
    Bookmark Topic Watch Topic
  • New Topic