是否可以同时使用RestyGwt和GWT材料设计?

时间:2019-04-18 08:16:14

标签: java resty-gwt gwt-material-design

我正在配置一个新项目,我想一起使用RestyGwt和Gwt Material Design,但是当我将RestyGWT添加到GWT模块时,我在客户端得到了ClassCastException。

我尝试将GWT Material Design版本降级到2.0,并在GWT模块和pom中添加以下行。

<inherits name="com.google.gwt.user.theme.clean.Clean" />
<inherits name="com.github.nmorel.gwtjackson.GwtJackson" />
<dependency>
    <groupId>com.github.nmorel.gwtjackson</groupId>
    <artifactId>gwt-jackson</artifactId>
    <version>0.14.2</version>
</dependency>

ClassCastException与Person类无关。当我添加空的MaterialDataTable时,会发生相同的问题 (或其他比按钮或标签更复杂的组件)添加到RootPanel。

Stacktrace

Error: java.lang.ClassCastException
    at RCc_g$.ah_g$ [as createError_0_g$] (Throwable.java:120)
    at RCc_g$.kh_g$ [as initializeBackingError_0_g$] (Throwable.java:112)
    at RCc_g$.Vg_g$ (Throwable.java:66)
    at RCc_g$.zh_g$ (Exception.java:29)
    at RCc_g$.Hh_g$ (RuntimeException.java:29)
    at new RCc_g$ (ClassCastException.java:27)
    at U0d_g$ (InternalPreconditions.java:154)
    at e1d_g$ (InternalPreconditions.java:138)
    at d1d_g$ (InternalPreconditions.java:133)
    at $_b_g$ (Cast.java:75)
    at sse_g$.tse_g$ [as setDisplay_1_g$] (FlexboxMixin.java:67)
    at sse_g$.Fse_g$ [as setGwtDisplay_0_g$] (FlexboxMixin.java:43)
    at Igg_g$.kie_g$ [as setGwtDisplay_0_g$] (MaterialWidget.java:400)
    at Pzi_g$.Mri_g$ [as setup_1_g$] (AbstractDataView.java:588)
    at kLi_g$.FJi_g$ [as onLoad_0_g$] (AbstractDataTable.java:153)
    at kLi_g$.ELi_g$ [as onLoad_0_g$] (MaterialDataTable.java:92)
    at kLi_g$.Eqc_g$ [as onAttach_0_g$] (Widget.java:359)
    at kLi_g$.Mqc_g$ [as setParent_0_g$] (Widget.java:484)
    at Ptc_g$.Uqc_g$ [as adopt_0_g$] (Panel.java:124)
    at Ptc_g$.erc_g$ [as add_6_g$] (ComplexPanel.java:105)
    at Ptc_g$.zrc_g$ [as add_4_g$] (AbsolutePanel.java:99)
    at K1d_g$.L1d_g$ [as onModuleLoad_0_g$] (Example.java:51)
    at Array.c3b_g$ (pl_00046solidmcg_00046cerber_00046webgwt_00046Cerber__EntryMethodHolder.java:3)
    at initializeModules_0_g$ (ModuleUtils.java:44)
    at Dp_g$ (Impl.java:309)
    at Gp_g$ (Impl.java:368)
    at Impl.java:78
    at w2b_g$ (ModuleUtils.java:55)
    at Example.java:122

GWT模块

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<module rename-to="Example">
    <inherits name='com.google.gwt.user.User'/>

    <inherits name="gwt.material.design.GwtMaterialWithJQuery" />
    <inherits name="gwt.material.design.addins.GwtMaterialAddins" />
    <inherits name="gwt.material.design.themes.ThemeBlue"/>
    <inherits name="gwt.material.design.GwtMaterialTable" />

    <inherits name="org.fusesource.restygwt.RestyGWT"/>

    <entry-point class="com.Example"/>

    <source path=''/>

    <extend-property name="locale" values="pl_PL"/>
    <set-property-fallback name="locale" value="pl_PL"/>
    <set-property name="locale" value="pl_PL"/>
</module>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>example-web-pom</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>example-web-gwt</artifactId>
    <packaging>war</packaging>

    <properties>
        <war.name>example</war.name>
        <gwt.material.version>2.1.1</gwt.material.version>
        <maven.deploy.skip>true</maven.deploy.skip>
        <maven.install.skip>true</maven.install.skip>
        <gwt.version>2.8.2</gwt.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.gwtmaterialdesign</groupId>
            <artifactId>gwt-material</artifactId>
            <version>${gwt.material.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.gwtmaterialdesign</groupId>
            <artifactId>gwt-material-addins</artifactId>
            <version>${gwt.material.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.gwtmaterialdesign</groupId>
            <artifactId>gwt-material-themes</artifactId>
            <version>${gwt.material.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.gwtmaterialdesign</groupId>
            <artifactId>gwt-material-jquery</artifactId>
            <version>${gwt.material.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.gwtmaterialdesign</groupId>
            <artifactId>gwt-material-table</artifactId>
            <version>${gwt.material.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>
                <executions>
                    <execution>
                        <id>Compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <runTarget>index.html</runTarget>
                    <port>${gwt.port}</port>
                    <productionMode>true</productionMode>
                    <extraJvmArgs>-Xmx2048M -Xms512M</extraJvmArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <warName>${war.name}</warName>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                            <excludes>
                                <exclude>**/*.swf</exclude>
                                <exclude>**/*.png</exclude>
                                <exclude>**/*.gif</exclude>
                                <exclude>**/*.wav</exclude>
                            </excludes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>

        <filters>
            <filter>${project.basedir}/src/main/filters/gwt_app.properties</filter>
        </filters>
    </build>
</project>

EntryPoint

package com.example;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

import gwt.material.design.client.ui.table.MaterialDataTable;

public class Example implements EntryPoint {

    @Override
    public void onModuleLoad() {

        MaterialDataTable<Person> materialTable = new MaterialDataTable<>();

        Person person = new Person();
        person.setName("name");
        person.setSurnName("surname");

        List<Person> personList = new ArrayList<>();
        personList.add(person);

        materialTable.setRowData(0, personList);

        RootPanel.get().add(materialTable);
    }

    public static class Person {
        private String name;
        private String surnName;


        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getSurnName() {
            return surnName;
        }

        public void setSurnName(String surnName) {
            this.surnName = surnName;
        }
    }
}

0 个答案:

没有答案