Failure reading parameter 'context' for pagelink
hi i've some problem with error:
I try to passed value integer from one page through pagelink anotger page using context .. code looks something like:
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;
}
}
Page Contact.tml:
<body>
<h1>Multiply Table Page 2</h1>
<p> Submit integer number N (1<=N<=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>
开发者_如何学JAVA </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 throws exception on line 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>
What is wrong, am i calling correctly the method multiplyValue?
I believe that context almost always expects the "value" to be property names, not an expression. So you want:
t:context="multiplyValue"
instead of
t:context="${multiplyValue}"
I would think it would do the expression and then convert it to a string (which is what usually happens in context parameters?, but then again, there's the error, so maybe not.
Update: (from asker of question in the comments) hi! i found out what is problem....problem was in method onSubmit() when i put rows[i]=i++; and columns[i]=i++ this was wrong.... i have to do: rows[i]=i+1; columns[i]= i+1
I guess I should have read through the code closer :)
精彩评论