通用标识符
因为我可能没有用正确的术语描述问题,所以我无法通过谷歌得到答案。请原谅!
在下面的代码中,我想用变量editedField替换“硬编码”标识符COMMENT。怎么做呢?
var editedField:String = event.dataField;
if (model.multipleProcessingData[i][editedInformationProductNO].COMMENT != null{
...
}
as I probably do not describe the problem in the right terms, I was not able to get an answer with google. Please excuse!
In the following code, I would like to replace 'hardcoded' identifier COMMENT with the variable editedField. How to do that?
var editedField:String = event.dataField;
if (model.multipleProcessingData[i][editedInformationProductNO].COMMENT != null{
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保将其包装在 NPE 的 try/catch 块中,因为您最终会找到具有这么多 [] 访问器的一个。
更好、更多的 OOP 是在模型上有一个访问器函数,您可以将数据传递给:
model.getEditedField(i,editedInformatioNProductNO,editedField)
如果事情没有像您预期的那样,这将使您更容易进行故障排除并向您的应用程序添加良好的错误消息。
Make sure you wrap this in try/catch block for NPE's, as you'll eventually find one with this many [] accessors.
A better, more OOP, would be to have an accessor function on your model that you can pass your data to:
model.getEditedField(i, editedInformatioNProductNO, editedField)
This will make it easier to troubleshoot and add good error messages to your app if things don't turn out like you expected.