欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
活用Bean(高級技術(shù),必讀)OBS [和訊博客]
0000491: 活用Bean(高級技術(shù),必讀)OBS
原創(chuàng )  
fy198392
2005-12-23 16:41:37
查看評論
 
大家是否碰到過(guò)一個(gè)畫(huà)面上有很多個(gè)具有一定規則的控件,卻不知道如何來(lái)控制他們呢?據個(gè)例子,畫(huà)面上有N排(0到100,具體數目根據數據庫得到),每排有5個(gè)列的Text控件。絕大多數人可能想去在A(yíng)ctionForm里,去定義N*5個(gè)String,或者想方設法.去定義一個(gè)數組來(lái)表示。第一種方法是很郁悶的,而第二種方法,脫離本課討論范圍,以后將給予介紹.
那到底如何解決按一定規則排序的Text按鈕呢?下面介紹另一種技術(shù),活用Bean。
Jsp:
<html:text property="sampleBean.sampleField" />
SampleForm:
private SampleBean sampleBean;
public SampleForm() {
this.sampleBean = new SampleBean();
}
sampleBean:
private String sampleField;
Action:
String str = getForm().GetSampleBean().GetField();
此時(shí)str內容為控件Text中輸入的內容
getForm().GetSampleBean().SetField(“你好”);
此時(shí)控件Text中顯示的內容為”你好”
那個(gè)N排(N由數據庫決定)有5個(gè)列的Text控件如何控制呢
<logic:present name=" sampleForm" property="sampleBeanList" >
<logic:iterateid="sampleBean"indexId="beanIndex"name="sampleForm "property=" sampleBeanList ">
<tr>
<td><html:text name="sampleBean" property="field1"/></td>
<td><html:text name="sampleBean" property="field2"/></td>
<td><html:text name="sampleBean" property="field3"/></td>
<td><html:text name="sampleBean" property="field4"/></td>
<td><html:text name="sampleBean" property="field5"/></td>
</tr>
</logic:iterate>
</logic:present>
SampleForm中定義
List sampleBeanList;
SampleBean:
String field1,....,String field5;
Action:
String str = getForm().GetSampleBeanList().get(2).SetField2();
此時(shí)str 內容為第三排,第二列控件Text中輸入的內容
getForm().GetSampleBeanList().get(2).SetField2(“你好”);
此時(shí)第三排,第二列控件Text中顯示的內容為”你好”
到此大家明白了嗎?
下面來(lái)個(gè)保留節目,上面的情況最后畫(huà)面輸出的是N行5列的固定矩形Text框集合.
如果最后畫(huà)面輸出行數固定列數不一,或者行數和列數都不定的Text框時(shí),該如何處理呢
<logic:iterate id="row" name="sampleForm" property="rowList" indexId="rowIndex">
<tr>
<logic:iterate id="column" name="row" indexId="columnIndex">
<td>
<bean:write name="column" property="code" />
<bean:write name="column" property="name" />
<html:hidden property="rowIndex" value="<%=rowIndex.toString()%>" />
<html:hidden property="columnIndex" value="<%=columnIndex.toString()%>" />
</td>
</logic:iterate>
</tr>
</logic:iterate>
SampleForm:
定義一個(gè)rowList,row又是一個(gè)List,里面是一個(gè)個(gè)數目不定的column.
每個(gè)column包含code和name.
Action里使用rowList時(shí),是把columnList作為假象的entity放入rowList中.
這樣每行的列數就可以根據每個(gè)columnList的size不定,列數發(fā)生變化.
List包含List,相對來(lái)說(shuō)可能比較復雜,但只要思路清楚了,也就不難了.
續開(kāi)講。昨天寫(xiě)了 “活用Bean(高級技術(shù),必讀) ID: 0000491”。主要針對畫(huà)面上的控件數組。記不記得,曾經(jīng)提到過(guò)還有第二種解決方案,今天討論一下。
昨天活用了Bean,因為Bean可以應付復雜的畫(huà)面而自己順意定義??墒钱旐椖繌碗s,畫(huà)面過(guò)多,那就不得不面臨另一個(gè)問(wèn)題。Bean Class的膨脹,數目過(guò)多,導致性能下降,或者操作繁瑣。
今天通過(guò)活用另一個(gè)標簽來(lái)靈活運用控件數組,那就是indexId。
Jsp:
<logic:iterate id="sample" name="sampleForm" indexId="index" property="sampleList">
<html:text property=‘<%= "sampleList[" + index+ "]" %>‘ />
</logic:iterate>
Form:
private String[] sampleList;
public String[] getSampleList() {
return sampleList;
}
public void setSampleList(String[] sampleList) {
this.sampleList= sampleList;
}
Action:
String[ ] sampleList= new String[3];
sampleList[0] = "0";
sampleList[1] = "1";
sampleList[2] = "2";
form.setSampleList(sampleList);
通過(guò)操作sampleList,可以得到和設置Text控件數組。
到此控件數組的講解,通過(guò)兩個(gè)活用結束了。兩種方法各有優(yōu)缺點(diǎn),到底用哪個(gè)自己衡量。
萬(wàn)事無(wú)定數,一切自己掌握。
luyw
2005/11/16
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
jsp標簽jsp:setProperty用法
Struts標簽
Struts1.x系列教程(7):Logic標簽庫
SSH開(kāi)發(fā)網(wǎng)上商店過(guò)程中遇到的16個(gè)問(wèn)題
JavaBean組件程序設計(3)
在 JSP/Servlet 中使用 Bean 自動(dòng)屬性填充機制(含原理分析)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久