我想实现的东东:在一个模块的页面用下拉框包含另一个模块所对应的表中的某一字段的值。所说的不同模块,就是对应不同的数据库中的表。
我自己的WaySelectionModel文件:
public class WaySelectionModel implements IPropertySelectionModel,Serializable {
    
private List wayList;
public WaySelectionModel(List wayList) {
this.wayList = wayList;
}    public int getOptionCount() { return wayList.size(); }    public Object getOption(int index) {
        return wayList.get(index);
    }    public String getLabel(int index) {
        return ((QuotaWorkingHour) wayList.get(index)).getWay();
    }    public String getValue(int index) { 
     return Integer.toString(index); 
    }    public Object translateValue(String value) {
     return getOption(Integer.parseInt(value));
    }
}
---------------------------------------------------------------
要实现下拉框页面的page文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC 
    "-//Apache Software Foundation//Tapestry Specification 4.0//EN" 
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"><page-specification class="org.appfuse.data.webapp.action.SalaryForm">    <inject property="engineService" object="engine-service:page"/>
    <inject property="request" object="service:tapestry.globals.HttpServletRequest"/>
    <inject property="response" object="service:tapestry.globals.HttpServletResponse"/>
    <inject property="salaryManager" type="spring" object="salaryManager"/>--我觉得要在此页面调用WaySelectionModel,是否应该在此表明???
    
    <inject property="quotaWorkingHourManager" type="spring" object="quotaWorkingHourManager"/>
    <inject property="quotaWorkingWeightManager" type="spring" object="quotaWorkingWeightManager"/>    <bean name="delegate" class="org.appfuse.webapp.tapestry.ValidationDelegate"/>
    <property name="message" persist="flash"/>    <component id="waySelection" type="PropertySelection">               ---------要调用数据库中数据作为下拉框的元素
        <binding name="value" value="salary.way"/>
        <binding name="model" value="waySelectionModel"/>               
        <binding name="displayName" value="message:salary.way"/>
    </component></page-specification>
------------------------------------------------------------
页面html文件:
.html文件:
<title><span key="salaryDetail.title"/></title>
<head><script src="/myapp/scripts/CalendarH.js"></script></head>
<content tag="heading"><span key="salaryDetail.heading"/></content><body jwcid="@Body"><span jwcid="@ShowValidationError" delegate="ognl:beans.delegate"/>
<span jwcid="@ShowMessage"/><form jwcid="salaryForm">
<ul><input type="hidden" jwcid="@Hidden" value="ognl:salary.id"/>    <li>
<td>
<span key="salary.way"/>                        -----------------调用下拉框的部分
</td>
<td>
<input jwcid="waySelection" type="text" id="way"/>
</td>
    </li>
</ul>
</form><script type="text/javascript">
    Form.focusFirstElement($("salaryForm"));
</script></body>
-------------------------------------------------------------
要实现下拉框页面对应的action文件:
     private WaySelectionModel model = null;    public WaySelectionModel getWaySelectionModel() {
     if(model== null) {
     List list = getQuotaWorkingHourManager().getAllQuotaWorkingHours();------调用getAllQuotaWorkingHours()方法取得表中所有数据。
     model = new WaySelectionModel(list);
     }
     return model;
    }    
    public abstract QuotaWorkingHour getWayItem();
    public abstract void setWayItem(QuotaWorkingHour value);    public void formSubmit(IRequestCycle cycle) {
   // Process form submission
    }
    public void pageDetached(PageEvent pageEvent) {
        model = null;
    }
-------------------------------------------------------------
跳转到此页面时报错:
org.apache.hivemind.ApplicationRuntimeException 
[Ljava.lang.Object; 
java.lang.ClassCastException 
[Ljava.lang.Object; 
………………请问是哪里的问题,我总觉得是不是page文件少引入东西的原因,还有我想问下:这个WaySelectionModel是什么时候实例化的?

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【weiyi00700】截止到2008-07-26 20:12:29的历史汇总数据(不包括此帖):
    发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:---------------------结分的百分比:---------------------
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html