Topic: Struts的几点总结

  Print this page

1.Struts的几点总结 Copy to clipboard
Posted by: dxy1999
Posted on: 2003-08-04 20:37

最近在作Struts的项目,现把我总结的几个技术问题的实现方法总结一下。
1.radio数组的实现
Action:

  ArrayList list = new ArrayList();

  list.add(0, new LabelValueBean("China", "000"));
  list.add(0, new LabelValueBean("Japan", "001"));

  instance.setChoSelectOutput(list);

  request.setAttribute("response", instance);

FormAction:
  
private String label;

  /**
   * @return
   */
  public String getLabel() {
     return label;
  }

  /**
   * @param string
   */
  public void setLabel(String string) {
     label = string;
  }

JSP:
   <logic:iterate id = "NewchoSelect" name = "response" property = "choSelectOutput" indexId = "j">

<td>
  <bean:define name="NewchoSelect" property="label" id="defineFoodName" type="String"/>
  <html:radio property="label" value='<%=defineFoodName%>'>
   <bean:write name="NewchoSelect" property="label"/>
  </html:radio>
</td>

</logic:iterate>

2.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: dxy1999
Posted on: 2003-08-04 20:44

组合框的实现
Action:
ArrayList list = new ArrayList();

list.add(0, new LabelValueBean("China", "000"));
list.add(0, new LabelValueBean("Japan", "001"));

instance.setCboNewsML_list(list);

request.setAttribute("response", instance);

JavaBean:

private ArrayList cboNewsML_list = null;
public ArrayList getCboNewsML_list() {
    return cboNewsML_list;
}

public void setCboNewsML_list(ArrayList cboNewsML_list) {
this.cboNewsML_list = cboNewsML_list;
}

JSP:
<bean:define id = "NewsML" name="response" property="cboNewsML_list"/>
<html:select property="cboNewsML" onchange="changeNewsML()">
<html:options collection="NewsML" property="value" labelProperty="label"/>
</html:select>

3.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: dxy1999
Posted on: 2003-08-04 20:46

3.Action的数据向javascript端传递
Action:

ArrayList list = new ArrayList();

list.add(0, new LabelValueBean("China", "000"));
list.add(0, new LabelValueBean("Japan", "001"));

instance.setCboNewsML_list(list);

request.setAttribute("response", instance);

JavaBean:

private ArrayList cboNewsML_list = null;

public ArrayList getCboNewsML_list() {
return cboNewsML_list;
}

public void setCboNewsML_list(ArrayList cboNewsML_list) {
this.cboNewsML_list = cboNewsML_list;
}

JavaScrtpt:
var a_kcontentscd = new Array();
var a_kcontentsnm = new Array();
<logic:iterate id="NewsMLKantere"
   name="response"
   property="cboNewsML_list"
   indexId="i">
   a_kcontentscd[<%=i%>] = '<bean:write name="NewsMLKantere" property="value" filter="false"/>';
   a_kcontentsnm[<%=i%>] = '<bean:write name="NewsMLKantere" property="label" filter="false"/>';
</logic:iterate>

4.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: dxy1999
Posted on: 2003-08-04 21:44

在jsp中,怎么判断bean的某一个值为null
bean:

private String strTest = null;

public ArrayList getStrTest() {
return strTest;
}

public void setStrTest (String strTest) {
this.strTest = strTest;
}

Action:

request.setAttribute("response", instance);
//instance is a instance of bean

JSP:
<logic:present name="response" property="strTest">
//strTest is not null
</logic:present>

5.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: floater
Posted on: 2003-08-05 02:16

Could you pleae reformat your code using the tag
 ... 

6.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: Johnny
Posted on: 2003-08-06 09:48

3x,very good,i like it
问一下你的action的东西是写在execute(perform)方法里的吗?

7.Re:Struts的几点总结 [Re: dxy1999] Copy to clipboard
Posted by: dxy1999
Posted on: 2003-08-07 15:12

是的。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923