将XML转换为JSON(Converting XML to JSON)
我试图将XML文件转换为
String
类型的内部表格。 有没有将XML数据转换为JSON格式的功能模块?I'm trying to convert an XML file into an internal table of type
String
. Is there a function module to convert XML data to JSON format?
原文:https://stackoverflow.com/questions/44260617
满意答案
GWT VerticalPanel是ComplexPanel的子类,ComplexPanel是包含多个子窗口小部件的Panel的抽象类。 在ComplexPanel中(由VerticalPanel继承)是获取子窗口小部件数量,通过索引获取对它们的引用等的方法。 你可以构建一个像这样的迭代器:
Iterator<Widget> vPanelWidgets = myVerticalPanel.iterator(); while (vPanelWidgets.hasNext()){ Widget childWidget = vPanelWidgets.next(); if (childWidget instanceof RadioButton) { ...do stuff } }
我倾向于不为其成员查询小部件。 根据你的例子,这与我对如何显示RadioButtons的决定联系在一起。 如果您稍后决定在FlexTable的单元格中显示单选按钮以控制垂直和水平排列,该怎么办? 要进行此更改意味着您的窗口小部件迭代器将无法工作。 FlexTable是Panel而不是ComplexPanel。 如果您决定使用FlexTable替换VerticalPanel,我上面编写的代码将无效。
如果要采取类似这种方法的东西,我会在某些Java Collection中保留我的相关小部件列表(如一组RadioButtons)。 我将该Collection传递给我的表示类,并在那里编写代码来进行布局。 通常这是一个UiBinder类,这些RadioButtons的“@UiField(provided = true)”。 然后,演示者中的代码将传入的Collection的RadioButton元素与UiBinder布局中的RadioButtons的UiField占位符相关联。 因此我的所有布局决策实际上都在UiBinder xml文件中。 如果我决定撕掉我的垂直面板并用FlexTable替换它,我可能不必触及一行Java代码,假设我把事情分开了。
[实际上,我可能会决定在表示层中使用RadioButtons,特别是在XML文件中。 该表示类将在EventBus上触发一条消息,指示用户已经通过RadioButton ValueChangeHandler进行了选择,我不在乎我是否在FlexPaable中的VerticalPanel或ToggleButtons中使用了RadioButtons。
A GWT VerticalPanel is a subclass of ComplexPanel, an abstract class for Panels that contain more than one child widget. In ComplexPanel (and so inherited by VerticalPanel) are methods for getting the number of child widgets, getting references to them by index, and so on. You could build an iterator something like this:
Iterator<Widget> vPanelWidgets = myVerticalPanel.iterator(); while (vPanelWidgets.hasNext()){ Widget childWidget = vPanelWidgets.next(); if (childWidget instanceof RadioButton) { ...do stuff } }
I tend not to query a widget for its members. That ties me to the decisions I made about how to display the RadioButtons, following your example. What if you decide later to display your radio buttons in the cells of a FlexTable in order to control vertical and horizontal arrangement? To make that change means your widget iterator won't work. FlexTable is a Panel but not a ComplexPanel. The code I wrote above won't work if you decide to replace the VerticalPanel with a FlexTable.
If was to take something like this approach, I would keep my lists of related widgets (like a group of RadioButtons) in some sort of Java Collection. I pass that Collection to my presentation class, and inside there I write the code to do the layout. Usually that's a UiBinder class, with "@UiField(provided = true)" for these RadioButtons. The code in the presenter then associates the RadioButton elements of the Collection I passed in to the UiField placeholders for the RadioButtons in the UiBinder layout. So all my layout decisions are actually in the UiBinder xml file. If I decide to rip out my Vertical Panel and replace it with a FlexTable, I might not have to touch a single line of Java code, assuming I separated things out correctly.
[Actually, I would probably keep my decision to use RadioButtons inside the presentation layer, and inside the XML file in particular. That presentation class would fire a message on the EventBus to indicate the user had made a selection via a RadioButton ValueChangeHandler, and I wouldn't care if I used RadioButtons in a VerticalPanel or ToggleButtons in a FlexTable.]
相关问答
更多Gwt获得组件(Gwt get Components)
如何在GWT 2.4中使用WAI-ARIA(How to use WAI-ARIA in GWT 2.4)
SpringROO + GWT定制(SpringROO+GWT customization)
从HTML / JS迁移到GWT(Moving from HTML/JS to GWT)
在“验证GWT组件”期间发生内部错误。(An internal error occurred during: “Validating GWT components”. GC overhead limit exceeded)
GWT MVP和SmartGWT兼容性(GWT MVP and SmartGWT compatibility)
GWT mvp:Places,RequestFactory和SmartGwt以及gwt-sl(GWT mvp : Places , RequestFactory and SmartGwt and gwt-sl)
GWT网页的复杂性(GWT web page complexity)
将EventBus与GWT组件一起使用的最佳实践(best practice to use EventBus with GWT components)
GWT JSNI方法曝光(GWT JSNI method exposure)
相关文章
更多net.sf.json解析json对象
让Solr返回JSON数据
数组数据 与json 的转换``
Json.Net学习笔记
怎么递归json嵌套json?
JSON是什么?
请教关于spring mvc中使用json-lib-ext-spring返回json的问题
XStream处理JSON
最新问答
更多您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
在计算机拍照在哪里进入
使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
单页应用程序:页面重新加载(Single Page Application: page reload)
在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!