|
30 | 30 | package nextapp.echo.extras.webcontainer.sync.component; |
31 | 31 |
|
32 | 32 | import java.io.IOException; |
| 33 | +import java.io.PrintWriter; |
33 | 34 |
|
34 | 35 | import javax.servlet.http.HttpServletRequest; |
35 | 36 |
|
@@ -114,6 +115,7 @@ public void service(Connection conn) |
114 | 115 |
|
115 | 116 | conn.setContentType(ContentType.TEXT_XML); |
116 | 117 | DomUtil.save(document, conn.getOutputStream(), null); |
| 118 | + DomUtil.save(document, new PrintWriter(System.err), null); |
117 | 119 | } catch (SerialException ex) { |
118 | 120 | throw new SynchronizationException("Unable to render model data.", ex); |
119 | 121 | } catch (SAXException ex) { |
@@ -222,13 +224,30 @@ public static void renderModelDataContent(Context context, ModelData modelData, |
222 | 224 | PropertyPeerFactory factory = (PropertyPeerFactory) context.get(PropertyPeerFactory.class); |
223 | 225 | int endIndex = Math.min(modelData.getEndIndex(), modelData.getModel().size()); |
224 | 226 | for (int i = modelData.getStartIndex(); i < endIndex; ++i) { |
225 | | - Element pElement = parentElement.getOwnerDocument().createElement("p"); |
226 | | - Object modelValue = modelData.getModel().get(i); |
227 | | - if (modelValue != null) { |
228 | | - SerialPropertyPeer modelValuePeer = factory.getPeerForProperty(modelValue.getClass()); |
229 | | - modelValuePeer.toXml(context, ViewerModel.class, pElement, modelValue); |
| 227 | + Object modelValue = modelData.getModel().get(i); |
| 228 | + if (modelValue == null) { |
| 229 | + Element pElement = parentElement.getOwnerDocument().createElement("p"); |
| 230 | + parentElement.appendChild(pElement); |
| 231 | + } else { |
| 232 | + if (modelValue instanceof Object[]) { |
| 233 | + Object[] array = (Object[]) modelValue; |
| 234 | + for (int iArray = 0; iArray < array.length; ++iArray) { |
| 235 | + if (array[iArray] == null) { |
| 236 | + continue; |
| 237 | + } |
| 238 | + Element pElement = parentElement.getOwnerDocument().createElement("p"); |
| 239 | + pElement.setAttribute("x", Integer.toString(iArray)); |
| 240 | + SerialPropertyPeer modelValuePeer = factory.getPeerForProperty(array[iArray].getClass()); |
| 241 | + modelValuePeer.toXml(context, ViewerModel.class, pElement, array[iArray]); |
| 242 | + parentElement.appendChild(pElement); |
| 243 | + } |
| 244 | + } else { |
| 245 | + Element pElement = parentElement.getOwnerDocument().createElement("p"); |
| 246 | + SerialPropertyPeer modelValuePeer = factory.getPeerForProperty(modelValue.getClass()); |
| 247 | + modelValuePeer.toXml(context, ViewerModel.class, pElement, modelValue); |
| 248 | + parentElement.appendChild(pElement); |
| 249 | + } |
230 | 250 | } |
231 | | - parentElement.appendChild(pElement); |
232 | 251 | } |
233 | 252 | } |
234 | 253 |
|
|
0 commit comments