如果我将它设置为相同的值,则在我的 bean 上调用 firePropteryChange() 不会执行任何操作
我有一个带有“fftLength”字段的bean。当我调用时,
public void setfftLength(String fftLength)
{
String oldfftLength = this.fftLength;
this.fftLength = fftLength;
changeSupport.firePropertyChange("fftLength", oldfftLength, fftLength);
}
我希望我的 GUI 对象能够反映更改。我使用 JGoodies Binding 绑定它。
问题是我有一个奇怪的极端情况,我需要使用相同的值调用设置器,因为我的模型和视图不同步。当我使用相同的值调用设置器时,什么也没有发生,我猜这是因为通常这将是一个浪费的操作。即使我设置相同的值,有没有办法强制 bean 更新?
I have a bean with a field "fftLength". When I call
public void setfftLength(String fftLength)
{
String oldfftLength = this.fftLength;
this.fftLength = fftLength;
changeSupport.firePropertyChange("fftLength", oldfftLength, fftLength);
}
I expect my GUI object to reflect the change. I bind it with using JGoodies Binding.
The problem is that I have this weird corner case where I need to call the setter with the same value because my model and view go out of sync. When I call the setter with the same value nothing happens, which I guess is because usually this would be a wasted operation. Is there a way to force the bean to update even though I am setting the same value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的答案是我永远不应该让模型和视图不同步。我和另一位工程师讨论过,这就是结论。即使我设置相同的值,也绝对没有办法强制 bean 更新。我通过在代码中考虑更高的几层来解决我的问题。我有一个操作顺序问题困扰着我,直到我与另一位工程师交谈后我才发现它:)
The correct is answer is that I should never let me model and view get out of sync. I talked about it with another engineer and that was the conclusion. There definitely is not a way to force the bean to update even though I am setting the same value. I fixed my problem by thinking a couple layers higher above in my code. I had an order of operation problem that was screwing me and I just didn't see it till after I spoke with the other engineer :)