2011-06-16 20 views
0

您好我一些問題,出現錯誤:失敗讀參數「語境」的pagelink

我使用上下文試圖通過價值整數從一個頁面通過pagelink anotger網頁..代碼看起來是這樣的:

public class Contact 
{ 

    @Persist 
    @Property 
    private Integer nNumb; 

    @Property 
    private Integer singleRow; 
    @Property 
    private Integer singleColumn; 

    @Persist 
    @Property 
    private Integer columns []; 
    @Persist 
    @Property 
    private Integer rows []; 

    @OnEvent 
    Object onSumbit(){ 
     rows = new Integer[nNumb]; 
     for (int i = 0; i < nNumb; i++) { 
      rows[i] = i++; 
     } 
     columns = new Integer[nNumb]; 
     for (int i = 0; i < nNumb; i++) { 
      columns[i] = i++; 
     } 
     return null; 
    } 
    public Integer getMultiplyValue(){ 
     return singleRow * singleColumn; 
    } 
} 

頁Contact.tml:

<body> 
     <h1>Multiply Table Page 2</h1> 
     <p> Submit integer number N (1&lt;=N&lt;=20): </p> 

    <t:form t:id="userInput"> 
     <p> 
      <t:label for="nNumb"/> 
      <t:textfield t:id="nNumb" t:label="N: " t:value="nNumb" t:validate="required,min=1,max=20" /> 
      </p> 
      <p> 
       <t:submit t:id="calculate" value="create multy table"/> 
       </p> 
    </t:form> 
    <h1>Result:</h1> 

    <table border="1"> 
     <tr> 
      <td bgcolor="#aaaaaa">*</td> 
      <td bgcolor="#aaaaaa" t:type="loop" t:source="columns" t:value="singleColumn"> 
       ${singleColumn} 
      </td> 
     </tr> 
     <tr t:type="loop" t:source="rows" t:value="singleRow"> 
       <td bgcolor="#aaaaaa">${singleRow}</td> 
       <td t:type="loop" t:source="columns" t:value="singleColumn"> 
       <a href="#" t:type="PageLink" t:page="product" t:context="${multiplyValue}">*</a> 
       </td> 
     </tr> 
    </table> 
    </body> 

pagelink拋出異常在線路34上:

Render queue error in BeginRender[Contact:pagelink]: Failure reading parameter 'context' of component Contact:pagelink: org.apache.tapestry5.ioc.internal.util.TapestryException 

32 <td bgcolor="#aaaaaa">${singleRow}</td> 
33 <td t:type="loop" t:source="columns" t:value="singleColumn"> 
34 <a href="#" t:type="PageLink" t:page="product" t:context="${multiplyValue}">*</a> 
35 </td> 
36 </tr> 

什麼是錯的,我是不是正確調用方法multiplyValue?

回答

1

我相信上下文幾乎總是期望「價值」是屬性名稱,而不是表達式。所以,你想:的

t:context="multiplyValue" 

代替

t:context="${multiplyValue}" 

我認爲它會做的表情,然後將其轉換爲字符串(這是通常發生在上下文中的參數?但話又說回來,有錯誤,所以也許不會

更新:!(從評論問題的提問者) 您好我發現了什麼問題....問題是在方法的onsubmit()時,IP ut rows [i] = i ++;和列[我] =我+這是錯誤的....我必須做的:rows [i] = i + 1;列[i] = I + 1

我想我應該通過代碼已經閱讀更接近:)

+0

幫我您好感謝,但仍然沒有工作...任何建議??? – dusmanka 2011-06-16 13:56:58

+0

它給你同樣的錯誤?不確定是否誠實。 – cgp 2011-06-16 14:02:09

+0

像以前一樣的錯誤..... – dusmanka 2011-06-16 14:10:47