jQuery.struts2_jquery is undefined

2,184 views
Skip to first unread message

Alexandre bizeau

unread,
May 23, 2012, 2:23:08 PM5/23/12
to struts2-jquery
Hello,

I had problem with a sjg.

The console give me 2 error and my grid didn't display at all.

Error 1 :
jQuery.struts2_jquery is undefined
jQuery.struts2_jquery.gridLocal = "en";

Error 2 :
jQuery.struts2_jquery is undefined
jQuery.struts2_jquery.require("js/struts2/
jquery.grid.struts2-3.2.1"+jQuery.struts2_jquery.minSuffix+".js");

So the probleme is with the jQuery for sure. I search a lot in this
group for issues like this one but none was good with this problem.


So my head look like :

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>

<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>

<%@ taglib prefix="s" uri="/struts-tags"%>

<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>

<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<htlm>

<head>

<sj:head jqueryui="true"/>

<script type="text/javascript">

/*

* Format a Column as Link

*/

function formatLink(cellvalue, options, row) {

return "<a href='#' onClick='javascript:openDialog("+cellvalue
+")'>" + cellvalue + "</a>";

}

</script>



<script type="text/javascript">



jQuery.subscribe('Create', function() {

alert('Affiche la grille avec bouton');

$('#ClientsTable tbody tr').slice(1).each(function(){

$(this).find('td:last').append('<button>Afficher</
button>').append('<button>Modifier</button>')});

});

</script>

</head>

And in the body, i create my grid like this :

<s:if test="listCompagnie.iterator.hasNext">

<s:url id="remoteurl" action="ClientsConsulterJSON"/>

<sjg:grid

id="ClientsTable"

caption="Liste des clients"

dataType="json"

href="%{remoteurl}"

pager="true"

gridModel="gridModel"

navigator="true"

navigatorEdit="false"

navigatorAdd="false"

navigatorView="true"

navigatorDelete="false"

rowList="10,20,50"

rowNum="10"

rownumbers="true"

viewrecords="true"

onGridCompleteTopics="Create">



<sjg:gridColumn name="id" index="id" title="CompagnieId"
sortable="true" editable="false" search="true" searchoptions="{sopt:
['eq','ne','bw','cn']}"/>



<sjg:gridColumn name="nom" index="nom" title="Nom"
sortable="true" editable="false" search="true" searchoptions="{sopt:
['eq','ne','bw','cn']}"/>



<sjg:gridColumn name="ville" index="ville" title="Ville"
sortable="true" editable="false" search="true" searchoptions="{sopt:
['eq','ne','bw','cn']}"/>



<sjg:gridColumn name="province" index="province" title="Province"
sortable="false" editable="false" search="false" cssStyle="text-
align:right;"/>



<sjg:gridColumn name="action" title="Actions" sortable="false"
editable="false"/>

</sjg:grid>

</s:if>

<s:else>

Aucun client...

</s:else>



Plugin call into my pom.xml :

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.1.2</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-grid-plugin</artifactId>
<version>3.2.1</version>
</dependency>

and i do my filter into my web.xml as well.


If more information is needed, i can provide as much as you need.


PS : Sorry if my english is a bit bad or if there french word use in
this part of the code.





jogep

unread,
May 23, 2012, 2:26:18 PM5/23/12
to struts2-jquery
Your JSP looks good, can you please post your web.xml?

Johannes
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep

On May 23, 8:23 pm, Alexandre bizeau <alexandrebiz...@gmail.com>
wrote:

Alexandre bizeau

unread,
May 23, 2012, 2:28:19 PM5/23/12
to struts2...@googlegroups.com
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Coteur</display-name>
 
    <context-param>
        <description>Registre PortailDistributeur</description>
        <param-name>registre_portaildistributeur</param-name>
        <param-value>192.168.1.217</param-value>
    </context-param>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
                       
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>


     <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <session-config> 
        <session-timeout>30</session-timeout> 
    </session-config>
   
</web-app>

jogep

unread,
May 23, 2012, 4:10:33 PM5/23/12
to struts2-jquery
Your filter mapping looks also good. Can you access the script
resources
generated by your <sj:head /> tag? especially this on:

<script type="text/javascript" src="/your-context/struts/js/struts2/
jquery.struts2-3.2.1.js"></script>
On May 23, 8:28 pm, Alexandre bizeau <alexandrebiz...@gmail.com>
wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app id="WebApp_ID" version="2.4"
> xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> > >                                         gridModel="gridModel"...
>
> read more »

Alexandre bizeau

unread,
May 24, 2012, 8:40:54 AM5/24/12
to struts2...@googlegroups.com
I talk with my colleague and I finally found my problem. I didn't even know but into the page.tag ( load with :<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>)

There was a line like this  :

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

so a conflit with the pom.xml depencies or something like that. I'm still looking for a solution to this problem because others pages jquery doesn't work because all of them use the tag.

Not my priority right now. Sorry for the trouble. I really like your grid. Still need to work on it and on my custom button added into. I'll try to add action on those custom button. I'm learning how to use jquery.appends right now and what can i do with this.

Have a nice day

Alexandre

2012/5/23 jogep <joh...@googlemail.com>

--
You received this message because you are subscribed to the Google Groups "struts2-jquery" group.
To post to this group, send email to struts2...@googlegroups.com.
To unsubscribe from this group, send email to struts2-jquer...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/struts2-jquery?hl=en.


Alexandre bizeau

unread,
Jul 9, 2012, 3:57:25 PM7/9/12
to struts2...@googlegroups.com

Just to tell to people who maybe looking for another possible problem I had with this again. Add this  : <sj:head jqueryui="true" />.

The main problem, it's because I forget this line always.
Reply all
Reply to author
Forward
0 new messages