java - GXT 如何在 XTemplate 中显示树对象?

标签 java gwt gxt

我有以下问题: 我正在一个复杂的 XTemplate 中显示我的 GXT 项目的数据。

@XTemplate(source = "DepictionDisplay.html")
    SafeHtml displayoben(String shortName, String inventoryNumber, String cave, String wall, String expedition, String vendor, String purchaseDate, String currentLocation, String stateOfPreservation, SafeUri imageUri, SafeUri fullImageUri,
            SafeUri realCaveSketchUri, double width, double height, String style, String modeOfRepresentation, String description, String generalRemarks, String otherSuggestedIdentifications); 

DepictionDisplay.html的相关部分是:

            <table class="data-view">
                <tpl if="inventoryNumber != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Inventory No.</i></td>
                        <td class="data-view-right">{inventoryNumber}</td>
                </tr>
                </tpl>
                <tpl if="cave != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Located in Cave</i></td>
                        <td class="data-view-right">{cave}</td>

                </tr>
                </tpl>
                <tpl if="wall != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Position in cave</i></td>
                        <td class="data-view-right">{wall}</td>
                </tr>
                </tpl>
                <tpl if="expedition != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Acquired by expedition</i></td>
                        <td class="data-view-right">{expedition}</td>
                </tr>
                </tpl>
                <tpl if="vendor != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Vendor</i></td>
                        <td class="data-view-right">{vendor}</td>
                </tr>
                </tpl>
                <tpl if="purchaseDate != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Purchase Date</i></td>
                        <td class="data-view-right">{purchaseDate}</td>
                </tr>
                </tpl>
                <tpl if="currentLocation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Current location</i></td>
                        <td class="data-view-right">{currentLocation}</td>
                </tr>
                </tpl>
                <tpl if="stateOfPreservation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>State of preservation</i></td>
                        <td class="data-view-right">{stateOfPreservation}</td>
                </tr>
                </tpl>
                <tpl if="style != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Style</i></td>
                        <td class="data-view-right">{style}</td>
                </tr>
                </tpl>
                <tpl if="modeOfRepresentation != &quot;&quot;">
                <tr style="border-bottom: 1px solid black">
                        <td class="data-view-left"><i>Mode of representation</i></td>
                        <td class="data-view-right">{modeOfRepresentation}</td>
                </tr>
                </tpl>
        </table>

问题是,最近,我不得不将 wall 的前字符串值更改为树对象。 树对象的条目有一个 getchildren() 函数来向下导航,还有一个 getText() 函数来访问要显示的字符串值。

我现在的问题是:如何在该表中显示树对象?到目前为止,我没有找到合适的选项,因为树的深度可以变化。

任何想法都会受到赞赏。

真诚的,

埃里克

最佳答案

XTemplates 可以采用 SafeHtml 参数并插入该内容,并且支持调用简单的格式化函数,但不能递归地调用自身或其他函数。

考虑迭代该 getChildren() 并将每个呈现的模板附加到 SafeHtmlBuilder,然后将生成的 SafeHtml 字符串传递给父级。然后,您自己的代码会执行递归,将较小的内容插入到较大的内容中。

关于java - GXT 如何在 XTemplate 中显示树对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61083464/

相关文章:

java - GWT 将两个按钮添加到 Cell<> 元素

java - 如何在 spring security/thymeleaf 中自动生成 csrf token 而不使用 @EnableWebMvcSecurity

java - Java 中的 SSLServerSocket 和 SSLSocket 握手异常

gwt - TabLelayoutPanel 将选项卡向右对齐

java - 如何实现gwt的嵌套 Activity

javascript - GXT 不工作

java - 如何将包含 double 值的 char 数组转换为 double 变量?

java - 如何对队列进行快照以避免无限循环

java - Seam 与哪些版本的 GWT 一起工作?

eclipse - GWT 编译使 JVM 崩溃