如何在没有action触发的情况下实例化一个组件

作者在SEAM框架中遇到消息组件未初始化的问题,在论坛求助后得到回复。回复指出,如果消息组件从未在页面中被访问过,则SEAM不会初始化它。解决办法是在类中手动调用工厂方法来初始化消息组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

郁闷,整了这么长时间,都没整出个结果。好多情况下就是这样,你越是不想干的事,不得不干,想干的事又没时间干。
这几天在seam forum上提问,终于有回答:
SmokingAPipe
 
If the cnMessages component has not been accessed from a page, then Seam will not have initialized it (ie, called the factory). Just because your other class is trying to access it, Seam doesn't know anything about that and won't magically call the factory method. That class will have to call the factory method manually, or do it some other way.
 
... ...
 
You need to have a @Begin method that initializes the cnMessages member. You're calling getCnMessage() before cnMessages has been set to anything. Tell me where is cnMessages being set? If you can answer that question you'll see what's going on. 
 
下一步该怎样呢? 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值