ColdSpring错误,当我不找一个Bean时,Bean不存在

时间:2012-03-26 14:32:33

标签: coldfusion coldfusion-9 coldspring

我正在为我自己的bean添加Mura CMS的插件,并且刚刚开始收到一个不存在的错误。我的一个bean有电子邮件,名称,数量等的setter和getter以及一些bean(即configBean,priceBean,teamBean)。

当我尝试加载bean(称为donationBean)时,我收到一条错误,即ID电子邮件中没有bean。电子邮件不应该基于bean。除了电子邮件的getter / setter之外,我没有添加任何代码,并且错误不会出现在任何其他属性中。这是捐赠bean的getter / setter部分:

  public numeric function getAmount(){ return Variables.data['amount']; }
  public void function setAmount(numeric amount){ Variables.data['amount'] = Arguments.amount; }

  public any function getConfigBean(){ return Variables.configBean; }
  public void function setConfigBean(any configBean){ Variables.configBean = Arguments.configBean; }

  public string function getEmail(){ return Variables.data['email']; }
  public void function setEmail(string email){ Variables.data['email'] = Arguments.email; }

  public string function getId(){ return Variables.data['id']; }
  public void function setId(string id){ Variables.data['id'] = Arguments.id; }

  public string function getName(){ return Variables.data['name']; }
  public void function setName(string name){ Variables.data['name'] = Arguments.name; }

  public boolean function getPaid(){ return Variables.data['paid']; }
  public void function setPaid(boolean paid){ Variables.data['paid'] = Arguments.paid; }

  public any function getPriceBean(){ return Variables.priceBean; }
  public void function setPriceBean(any priceBean){ Variables.priceBean = Arguments.priceBean; }

  public numeric function getTeamId(){ return Variables.data['teamid']; }
  public void function setTeamId(numeric teamid){ Variables.data['teamid'] = Arguments.teamid; }

这是我的config.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
  <bean id="registrationBean" class="[plugin]lib.registration" />
  <bean id="priceBean" class="[plugin]lib.price" />
  <bean id="donationBean" class="[plugin]lib.donation" />
</beans>

最后我的代码加载bean(来自bean本身):

  public any function createForTeamPayment(priceid, teamid, name, email){
    var price = getPriceBean().loadBy({priceid=Arguments.priceid});
    setAmount(price.getAmount());
    setTeamId(Arguments.teamid);
    setName(Arguments.name);
    setEmail(Arguments.email);
    save();
  }

2 个答案:

答案 0 :(得分:0)

我发现如果我将电子邮件属性更改为另一个名称,在我的案例中是donorEmail,那么一切都开始起作用了。我不知道为什么,因为没有带有ID电子邮件的bean,并且它没有被称为bean。

答案 1 :(得分:0)

很可能是名称空间冲突...... EmailID在mura名称空间中... 您可以尝试为变量设置本地范围...

结帐〜要求\ mura \ bean \ beanFactory.cfc ...

    <cfset variables.transientAlias["email"]="emailBean"/>

也是要求\ mura \ email \ emailBean.cfc

    <cfcomponent extends="mura.bean.bean" output="false">

    <cfproperty name="emailID" type="string" default="" required="true" />