我正在学习如何使用tapestry,并且我不断遇到以下错误
Exception: source is null for getProperty(null, "agent")
ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2203)
这是我的html页面中的代码
<tr>
<td valign="center" align="right" height="30"><span class="label1"> <span key="agentDeletionSalesParentActivityType" /> : </span></td>
<td valign="center" align="left" height="30"><select jwcid="agentDeletionSalesParentActivityType@ActivityTypePropertySelection" regions="ognl:{activity.agent.region}" emptyOption="true" disabled="ognl:disabled" value="ognl:parentActivityType" /></td>
</tr>
<tr>
<td valign="center" align="right" height="30"><span class="label1"> <span key="agentDeletionSalesChildActivityType" /> : </span></td>
<td valign="center" align="left" height="30"><select jwcid="agentDeletionSalesChildActivityType" regions="ognl:{activity.agent.region}" emptyOption="true" disabled="ognl:disabled" value="ognl:childActivityType" parent="component:agentDeletionSalesParentActivityType" /></td>
</tr>
这是我的java代码
@Persist
public abstract ActivityType getParentActivityType();
public abstract void setParentActivityType(ActivityType parent);
@Persist
public abstract ActivityType getChildActivityType();
public abstract void setChildActivityType(ActivityType child);
@Component(id="agentDeletionSalesChildActivityType", type="ActivityTypePropertySelection")
public abstract ActivityTypePropertySelection getChildActivityPropertySelection();
如果您需要更多代码,我会很乐意将其保留(保持较小以免将代码堆入页面),任何人都可以看到为什么会返回此异常?
答案 0 :(得分:2)
这似乎是说activity
对象在此处为空:
regions="ognl:{activity.agent.region}"
答案 1 :(得分:0)
不确定你是否设法解决了这个问题,但我遇到了问题。
您的配置与我的差异是嵌套对象引用
regions="ognl:{activity.agent.region}"
由于您的例外情况:
Exception: source is null for getProperty(null, "agent")
根据我的经验,这意味着activity
确实是空的,正如@Stephen C所说。
我收到的例外是:
Exception: source is null for getProperty(null, "question")
这是我的配置。希望你能够发现一些见解。
SetSecurityQuestions.page
<component id="securityQuestion1Dropdown" type="PropertySelection">
<binding name="model" value="securityQuestion1Model"/>
<binding name="displayName" value="message:security_question_1"/>
<binding name="value" value="securityQuestion1.question"/> <!-- the offending line -->
</component>
SetSecurityQuestions.html
<div class="formline">
<span class="formtext">
<span jwcid="@company:FieldLabelWithColon"
field="component:securityQuestion1Dropdown"
title="Security Question 1"
key="security_question1">Security Question 1</span>
<span class="mandatory">*</span>
</span>
<select jwcid="securityQuestion1Dropdown" tabindex="1"/>
</div>
SetSecurityQuestions.java
@Persist("session")
@InitialValue("new com.org.net.SecurityQuestion()") // the solution
public abstract SecurityQuestion getSecurityQuestion1();
public abstract void setSecurityQuestion1(SecurityQuestion securityQuestion1);
希望有所帮助。