Problem z wyświetlaniem podstrony

0

Witam!
Robię aplikację przy użyciu m.in Spring MVC, Apache Tiles i jQuerry Table.

konfiguracja Tiles

public final class TilesDefinitionsConfig implements DefinitionsFactory{

    private static final Map<String,Definition> tilesDefinitions = new HashMap<>();
    private static final Attribute BASE_TEMPLATE = new Attribute("/WEB-INF/Views/tiles/layouts/layout.jsp");

    @Override
    public Definition getDefinition(String name, Request tilesContext) {
        return tilesDefinitions.get(name);
    }

    private static void addDefaultLayoutDef(String name, String title, String body) {
        Map<String, Attribute> attributes = new HashMap<>();

        attributes.put("title", new Attribute(title));
        attributes.put("header", new Attribute("/WEB-INF/Views/tiles/template/header.jsp"));
        attributes.put("menu", new Attribute("/WEB-INF/Views/tiles/template/menu.jsp"));
        attributes.put("body", new Attribute(body));
        attributes.put("footer", new Attribute("/WEB-INF/Views/tiles/template/footer.jsp"));

        tilesDefinitions.put(name, new Definition(name, BASE_TEMPLATE, attributes));
    }

    public static void addDefinitions(){
        addDefaultLayoutDef("home","Home", "/WEB-INF/Views/Page/home.jsp");
    }

    public static void addDefinitionsSystem() {
        addDefaultLayoutDef("system","Systemy", "/WEB-INF/Views/Page/system.jsp");
    }

    public static void addDefinitionsDeal() {
        addDefaultLayoutDef("deal","Umowy", "/WEB-INF/Views/Page/deal.jsp");
    }

    public static void addDefinitionsContact() {
        addDefaultLayoutDef("contact","Kontakt", "/WEB-INF/Views/Page/contact.jsp");
    }
}

przykład - system.jsp gdzie jest tabela

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <link href="<c:url value='static/themes/lightcolor/blue/jtable.css' />" rel="stylesheet" type="text/css" />
    <link href="<c:url value='static/jquery-ui.min.css" rel="stylesheet' />" type="text/css" />

    <script type="text/javascript" src="static/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="static/jquery-ui.min.js"></script>
    <script type="text/javascript" src="static/jquery.jtable.min.js" ></script>
    <script type="text/javascript" src="static/jquery.jtable.js"></script>
    <script type="text/javascript" src="static/system.js"></script>
</head>
<body>
<div id="systemResultsDiv"></div>
</body>
</html>

Niestety wyświetlana jest pusta strona. ( Za wyjątkiem layoutu - tu jest wszystko jak należy)
Jakieś sugestie aby rozwiązać ten problem??

0

w php by działało

{{ :) }}

0

Te metody:
public static void addDefinitions()
Są gdzieś wywoływane?
Jak będę w domu, to poszukam, czy gdzieś nie mam przykładu z tilesami i mvc

0

Tak, w AppConfig


  @Bean
    public TilesConfigurer getTilesConfigurer() {
        TilesConfigurer tilesConfigurer = new TilesConfigurer();
        tilesConfigurer.setCheckRefresh(true);
        tilesConfigurer.setDefinitionsFactoryClass(TilesDefinitionsConfig.class);

        // Add apache tiles definitions
        TilesDefinitionsConfig.addDefinitions();
        TilesDefinitionsConfig.addDefinitionsSystem();
        TilesDefinitionsConfig.addDefinitionsDeal();
        TilesDefinitionsConfig.addDefinitionsContact();

        return tilesConfigurer;

    }

0

W jspie jeszcze musisz jakoś przekazać, co chcesz pokazać z tilesa, przykład:

<head></head>
<body>
	<tiles:insertAttribute name="header" />
	<div id="container">
		<tiles:insertAttribute name="sidebar" />
		<div id="content" >
			<tiles:insertAttribute name="body" />
		</div>
	</div>
	<div id="footer">
0

Wiem, tak mam zrobione w layout. Dokładnie jak napisałeś. Po menu jak przechodzę to strony się otwierają - razem z css. Natomiast w sysytem.jsp powinna być tabela z jQuery DataTable i nie chce mi czytać jej.
Zanim utworzyłem layout za pomocą Apache Tiles - sama tabela jako osobna strona się otwierała bez problemu. Gdy wrzuciłem kod do sekcji body nie otwiera się. Nie chce czytać pliku js.

system.js

$(document).ready(function() {
    $('#systemResultsDiv').jtable({
        title :'Lista Systemów',
        actions : {
            listAction : function (postData, jtParams) {
                return $.Deferred(function ($dfd) {
                    $.ajax({
                        url: 'get',
                        type: 'GET',
                        dataType: 'json',
                        data: postData,
                        success: function (data) {
                            $dfd.resolve(data);
                        },
                        error: function () {
                            $dfd.reject();
                        }
                    });
                });
            },
            createAction : 'save-edit',
            updateAction : 'save-edit',
            deleteAction : 'delete'
        },
        fields : {
            systemId : {
                title : 'Id Systemu',
                key : true,
                width : '5%'
            },
            systemName : {
                title : 'Nazwa Systemu',
                width : '15%',
                type : 'hidden-edit'
            },
            systemDescription : {
                title : 'Opis Systemu',
                width : '35%'
            },
            technology : {
                title : 'Technologie',
                width : '30%'
            },
            systemOwner: {
                title : 'Właściciel',
                width : '10%'
            }
        }
    });
    $('#systemResultsDiv').jtable('load');
});

0

Problem rozwiązany. Przeniosłem wszystkie linki i scrypty z head system.jsp do layout.jsp i ruszyło.
Problem mam teraz taki - tabela nie wyświetla jakichkolwiek wpisów - No data available!.

Gdy do adresu strony dodam /get wszystkie pozycje są wyświetlone za pomocą JSONA, natomiast tabela jest pusta. Gdy za pomocą przycisku Add new record chcę dodać nowy obiekt - wpiszę wszystko daję zapisz, wyskakuje mi error ale w bazie danych nowy obiekt zostaje zapisany.
W logach mam pusto. Żadnego błędu czy ostrzeżenia.

1 użytkowników online, w tym zalogowanych: 0, gości: 1