Integration Problems between Spring Security & Dandelion

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Integration Problems between Spring Security & Dandelion

Ángel Antón
Hi there,

I recently have started using Thymeleaf. I have a problem integrating Spring Security and Dandelion. I don´t know if it's something I'm doing wrong.

I'm using:

- Spring security: 3.1.2
- Thymeleaf: 2.1.0
- Tymeleaf Security: 2.1.0
- Dandelion: 0.9.2

My conf. file:

       <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
          <property name="templateResolver" ref="templateResolver" />
          <property name="additionalDialects">
        <set>
          <bean class="com.github.dandelion.datatables.thymeleaf.dialect.DataTablesDialect"/>
          <bean class="org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect"/>
        </set>
      </property>
       </bean>
       
       <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
          <property name="templateEngine" ref="templateEngine" />
       </bean> 

And when I try to load the login page it results on an error like this:

GRAVE: El Servlet.service() para el servlet [admin] en el contexto con ruta [/console] lanzó la excepción [Handler processing failed; nested exception is java.lang.AbstractMethodError] con causa raíz
java.lang.AbstractMethodError
       at org.thymeleaf.DialectConfiguration.initialize(DialectConfiguration.java:137)
       at org.thymeleaf.Configuration.initialize(Configuration.java:166)
       at org.thymeleaf.TemplateEngine.initialize(TemplateEngine.java:827)
       at org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:203)
       at org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:190)
       at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1157)
       at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
       at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
       at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
       at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
       at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)


After this error, I replaced dandelion with pagesdialect:

        <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
           <property name="templateResolver" ref="templateResolver" />
           <property name="additionalDialects">
        <set>
          <bean class="org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect"/>
          <bean class="net.sourceforge.pagesdialect.PagesDialect" />
        </set>
      </property>
        </bean>
         
        <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
           <property name="templateEngine" ref="templateEngine" />
        </bean> 

and everything works just fine.

I would like to use Dandelion extension, but It seems I can't make it works with Spring Security.
Anybody has the same problem?

Thanks in advance!!!
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Thibault Duchateau
Hi!

I hadn't taken the time to test the compatibility since the first release of the 2.1.X but I should have :-/

The problem comes from a custom implementation of the IElementNameProcessorMatcher, not tested with later releases than the 2.0.19.
So, if you want to use Dandelion, I'm afraid you're stuck with Thymeleaf 2.0.19.

Since Dandelion-Datatables 0.10.0 in unlikely to be released for a while yet, I'll probably release a 0.9.3 embeding the compatibility with 2.1.x+ and the latest PR. Should be at the end of the week.

Sorry for the inconvenience. :-/

Regards,
Thibault
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Thibault Duchateau
Hi!

Dandelion-Datatables 0.9.3 has been released!
Feel free to upgrade, it should fix your issue.

Regards,
Thibault
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

danielfernandez
Administrator
Thanks awfully, guys!
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Ángel Antón
In reply to this post by Thibault Duchateau
Thanks for such a quick response! I'll check it out!
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

nik10.mah
In reply to this post by Thibault Duchateau
Thanks for the 0.9.3 version it did resolved the exception but now I am getting datatables re-initialization error on each page where ever i have implemented dandelion datatables. I was previously using 0.8.14 version and after upgrading to 0.9.3 i am now starting getting rei-nitialization error.


Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Thibault Duchateau
Hi,

Could you please post a bit more information?

For example:
* an example usage of the dialect
* the interesting part of the stacktrace

Thanks.

Regards,
Thibault.
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

nik10.mah
Hi ,

here is my code to initialize the datatables in my html file.

            <table id="myTable" dt:table="true" dt:paginationType="'input'">
                <thead>
                    <tr>
                        <th th:text="#{department.list.name}">department Name</th>
                        <th dt:filterable="true" dt:visible="false" dt:filterType="'select'">All</th>
                        <th class="statusColumn" th:text="#{common.status}"></th>
                        <th class="actionColumn" th:text="#{common.actions}" dt:searchable="false" dt:sortable="false">Actions</th>
                    </tr>
                </thead>
                <tbody th:remove="all-but-first">
                    <tr th:each="department,stat : ${departments}">
                        <td th:text="${department.departmentName}">department</td>
                        <td class="statusColumn" th:text="${department.status}">department</td>
                        <!--/* This code will be removed at thymeleaf parsing time! */-->
                        <td class="statusColumn" th:text="${department.status == 1}  ? #{common.activated} : #{common.deactivated}"></td>
                        <td class="actions">
                            <ul>
                                <li><a class="edit" href="#" th:href="@{'/department/edit/' + ${department.departmentId}}" th:title="#{common.edit}">1</a></li>
                                <li th:if="${department.parent!=null}"></li>
                                <li th:if="${department.status==2}"><a class="activate" href="#" th:href="@{'/department/toggle/' + ${department.departmentId}}" th:title="#{common.activate}">2</a></li>
                                <li th:if="${department.status==1 and department.departmentId!=session.currentDepartment.departmentId}"><a class="deactivate" href="#" th:href="@{'/department/toggle/' + ${department.departmentId}}" th:title="#{common.deactivate}">3</a></li>
                                <li th:if="${department.status==2}"><a class="delete" href="#" th:href="@{'/department/delete/' + ${department.departmentId}}" th:onclick="'<a class="moz-txt-link-freetext" href="javascript:return">javascript:return DEPARTMENT.LIST.deleteDepartment(\'' + ${department.departmentId} + '\', \'' +${department.departmentName}+ '\' );'" th:title="#{common.delete}">4</a></li>

                            </ul>
                        </td>

                    </tr>
                </tbody>
            </table>


And in javascript i am also retrieving the same object for search and filter custmization. Here is my Javascript code.

function filterEvents(filter) {

    // var isAllSelected = false;
    var allOption = filter.all;
    var filterOption = filter.option;
    var filterCol = filter.filterCol;
    // var filterLink = filter.link;
    var isStatusEl = filter.isStatusEl;

    // Events for the checkbox filter
    var oTable = $('#myTable').dataTable();

    $(allOption).click(function() {
        allOptionClick(filter, this);
        $(filterOption).prop("checked", this.checked);
        oTable.fnFilter('', filterCol);

        // This condition is used to find that is the clicked element belongs to
        // status drop down
       
         * if(isStatusEl != undefined){ this.checked ? $(".statusColumn").show() :
         * $(".statusColumn").hide(); }
         
        var regex = "(.*( ";
        $(filterOption + ":checked").each(function(index) {
            if (index == 0) {
                regex += $(this).val();
            } else {

                regex += " )|( " + $(this).val();
            }
        });

        regex += " ).*)";
        if ($(filterOption).length == $(filterOption + ":checked").length) {
            $(allOption).prop("checked", "checked");
            isAllSelected = true;
        } else {
            $(allOption).removeAttr("checked");
            isAllSelected = false;
        }
        oTable.fnFilter(regex, filterCol, true);
        if (isPageLoadCompleted)
            setCheckBoxFiltersStateAllChecked(this.id, "");
    });

    $('#tableSearch').on("change keyup click", function() {
        oTable.fnFilter(this.value);
    });

    $(filterOption).click(function() {
        if ($(filterOption).is("input")) {
            filterOptionClick(filter);
            var regex = "(.*( ";
            $(filterOption + ":checked").each(function(index) {
                if (index == 0) {
                    regex += $(this).val();
                } else {

                    regex += " )|( " + $(this).val();
                }
            });

            regex += " ).*)";
            if ($(filterOption).length == $(filterOption + ":checked").length) {
                $(allOption).prop("checked", "checked");
                isAllSelected = true;
            } else {
                $(allOption).removeAttr("checked");
                isAllSelected = false;
            }

            oTable.fnFilter(regex, filterCol, true);

            // This condition is used to find that is the clicked element
            // belongs to status drop down
            if (isStatusEl != undefined) {
                isAllSelected ? $(".statusColumn").show() : $(".statusColumn").hide();
            }
        } else {
            regex = "(.*( " + $(this).val() + " )*.)";
            oTable.fnFilter(regex, filterCol, true);
        }
        if (isPageLoadCompleted)
            setCheckBoxFiltersState(this.id, "");
    });
}
 PFA the screen shot of the JS error alert that i am getting.

Thanks and Regards,
Nikhil


On 04-Dec-13 12:36 PM, tduchateau [via Thymeleaf - User Forum] wrote:
Hi,

Could you please post a bit more information?

For example:
* an example usage of the dialect
* the interesting part of the stacktrace

Thanks.

Regards,
Thibault.


If you reply to this email, your message will be added to the discussion below:
http://forum.thymeleaf.org/Integration-Problems-between-Spring-Security-Dandelion-tp4027148p4027243.html
To unsubscribe from Integration Problems between Spring Security & Dandelion, click here.
NAML


onload-error.png (76K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

nik10.mah
In reply to this post by Thibault Duchateau
Hi,
 It seems like the line
var oTable = $('#myTable').dataTable();
 is generating new instance of datatable every time instead of getting  existing instance of datatable.


Thanks,
Nikhil Mahajan

On 04-Dec-13 12:36 PM, tduchateau [via Thymeleaf - User Forum] wrote:
Hi,

Could you please post a bit more information?

For example:
* an example usage of the dialect
* the interesting part of the stacktrace

Thanks.

Regards,
Thibault.


If you reply to this email, your message will be added to the discussion below:
http://forum.thymeleaf.org/Integration-Problems-between-Spring-Security-Dandelion-tp4027148p4027243.html
To unsubscribe from Integration Problems between Spring Security & Dandelion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Thibault Duchateau
Hi!

Sorry for the delay. :-(
Indeed, the issue comes from the second initialization of DataTables in your custom function.

@Daniel: since it's more a Dandelion/DataTables issue, maybe you prefer we switch to the Dandelion forum before continuing?
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

danielfernandez
Administrator
Oh, OK, whatever you prefer. I suppose it would be more comfortable for you to move to the Dandelion forum, esp. for documentation purposes.

Anyway, you know you are always welcome here ;)
Reply | Threaded
Open this post in threaded view
|

Re: Integration Problems between Spring Security & Dandelion

Thibault Duchateau
This post was updated on .
@Nikhil: let's continue the discussion in a new topic created on the Dandelion forum.

@Daniel: oooww... <3
:-)


Thibault