• Post Reply Bookmark Topic Watch Topic
  • New Topic

some jsp conversion from struts1 to struts2  RSS feed

 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I am doing revamp project from struts1 to struts2. I have studied for some time and going to amend Jsp Page. Below is some extract from struts1 framework jsp file:
Please let me know some conversion tips or example. I really in doubt about the javascript client side and struts2 server side exchange. e.g.  var form = document.forms['CardForm'] ..........


<%@ page import="java.io.*, java.util.*" %>
<%@ page import="com.awip.hibernate.SCardTypeCat" %>
<%@ page import="com.awip.hibernate.SCardTypeCatDesc" %>
<%@ 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"%>
<bean:define id="days"   name="CardForm" property="dayRange"   type="java.util.Collection" />
<bean:define id="months" name="CardForm" property="monthRange" type="java.util.Collection" />
<bean:define id="years"  name="CardForm" property="yearRange"  type="java.util.Collection" />

//----------------------------------------------
var form = document.forms['CardForm'];

//-------------------------------------------------

function cardTypeOnChange(objField) {
<%

if (jalCardType!=null && !jalCardType.equals("")){ %>
if (objField.value == '<%=jalCardType %>'){
var elem = document.getElementById('jalMembershipNoRow');
if (elem!=null){
var html ='<DIV class="row"><DIV class="title1"><SPAN

class=title><bean:message bundle="cardResources" key="label.jal.membershipno" /></SPAN></DIV>';
html = html + '<DIV class="longfield"><INPUT class="shortinput"

maxLength="48" type="text" name="jalMembershipNo" value="<%=jalMembershipNo %>"> ';
html = html + '<BR/><SPAN ID="jalRemark" style="color:#999; line-

height:18px;"><bean:message bundle="cardResources" key="label.person.jal.remark" /></SPAN> ';
                        //**** BEGIN MAK2302 ****
html = html + '<BR/><B ID="jalRemark2" style="color:red; line-

height:18px;"><bean:message bundle="cardResources" key="label.person.jal.remark2" /></B> ' ;

html = html + '</DIV></DIV>';
elem.innerHTML = html;
}
var elem1 = document.getElementById('emailRemark');
if (elem1){ elem1.innerHTML = '<bean:message bundle="cardResources"

key="label.person.email.remark2" />'; }

var elem3 = document.getElementById('cardTermsTextarea');
if (elem3){ elem3.value = '<bean:message bundle="cardResources"

key="label.tnc.content2" />'; }
showOptOutForJAL();
}
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delete below:
<%@ 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"%>
<bean:define id="days"   name="CardForm" property="dayRange"   type="java.util.Collection" />
<bean:define id="months" name="CardForm" property="monthRange" type="java.util.Collection" />
<bean:define id="years"  name="CardForm" property="yearRange"  type="java.util.Collection" />

Add Below and change tab to using structs2-tab, e.g. s:label...
<%@ taglib prefix="s" uri="/struts-tags"%>

But i still do not know how to interact between javascript and struts2 MVC or Spring ??
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I have amended my JSP file but display in the attached screen with no label text. I am using <s:label name="xxxx.xxx.xx"/>
But it cannot display. When view on source html, it is <label id=XXXXCard?method?xxxx_xxx_xx />
error.png
[Thumbnail for error.png]
 
Raymond Chiu Wing Hing
Ranch Hand
Posts: 87
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raymond Chiu Wing Hing wrote:Dear all,

I have amended my JSP file but display in the attached screen with no label text. I am using <s:label name="xxxx.xxx.xx"/>
But it cannot display. When view on source html, it is <label id=XXXXCard?method?xxxx_xxx_xx />


Type wrong:  <label id=XXXXCard?method=xxxx_xxx_xx />
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!