1

我只是在学习如何使用挂毯,但我不断遇到以下错误

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" />&nbsp;:&nbsp;</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" />&nbsp;:&nbsp;</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();

如果您需要更多代码,我会很乐意将其放上去(保持较小,以免将代码堆积到页面中),任何人都知道为什么会返回此异常吗?

4

2 回答 2

2

这似乎是说该activity对象在此为空:

regions="ognl:{activity.agent.region}"
于 2012-10-10T11:31:20.570 回答
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);

希望有帮助。

于 2014-06-02T10:56:53.837 回答