bonjour tout le monde ,je suis débutant dans l'utilisation de json et ça fait une semaine que je me suis confronté avec le problème de grid . la grid m'affiche rien et dans le console je reçois ces messages
[WARN,ServletUrlRenderer,http-8080-2] No configuration found for the specified action: 'bonreception2' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
[WARN,ServletUrlRenderer,http-8080-2] No configuration found for the specified action: 'bonreception2' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
[WARN,ServletUrlRenderer,http-8080-2] No configuration found for the specified action: 'bonreception3' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
[WARN,ServletUrlRenderer,http-8080-2] No configuration found for the specified action: 'bonreception3' in namespace: '/'. Form action defaulting to 'action' attribute's literal value.
size de commercants 26
size de commercants 26
dans Struts.xml j'ai
1 2 3 4 5 6 7 8 9 10 11 12 13
| <struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.convention.result.path" value="/pages"/>
<constant name="struts.custom.i18n.resources" value="messages" />
<package name="voucher" extends="struts-default,json-default" namespace="/">
<action name="recherche_reception1" class="ma.pcard.voucher.action.RechCmdDistListAction">
<result name="success">/JSP/menu_order/order_distributeur/recherche/achatfinddetail.jsp</result>
<result name="input">/error.jsp</result>
</action>
</package>
</struts> |
dans la page jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<sj:head jqueryui="true" jquerytheme="redmond" />
</head>
<body>
<s:url id="remoteurl" action="recherche_reception1"/>
<sjg:grid
dataType="json"
name="grid"
caption="amine"
href="%{remoteurl}"
height="400"
width="400"
gridModel="gridModel"
>///////////////nomCom est un attribut de l'entité Commercant
<sjg:gridColumn name="nomCom" index="nomCom" title="nom" />
</sjg:grid>
</body>
</html> |
dans l'action java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| public class RechCmdDistListAction extends ActionSupport implements SessionAware{
/**
*
*/
private Map<String, Object> session;
private CommercantManager commercantManager;
private List<Commercant>gridModel;
private List<Commercant> commercants;
public String execute() throws Exception
{
this.session=getSession();
ApplicationContext ctx=WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());
commercantManager=(CommercantManager) ctx.getBean("commercantManager");
commercants = commercantManager.getAllCommercants();
System.out.println("size de commercants "+commercants.size());
Object list = session.get("mylist");
if (list != null)
{
commercants = (List<Commercant>) list;
}
else
{
commercants = commercantManager.getAllCommercants();
}
setGridModel(commercants);
//Your logic to search and select the required data.
session.put("mylist",commercants);
//calculate the total pages for the query
return SUCCESS;
// TODO: handle exception
}
public String getJSON() throws Exception
{
return execute();
}
public CommercantManager getCommercantManager() {
return commercantManager;
}
public void setCommercantManager(CommercantManager commercantManager) {
this.commercantManager = commercantManager;
}
public List<Commercant> getGridModel() {
return gridModel;
}
public void setGridModel(List<Commercant> gridModel) {
this.gridModel = gridModel;
}
public Map<String, Object> getSession() {
return session;
}
public void setSession(Map<String, Object> session) {
this.session = session;
}
public List<Commercant> getCommercants() {
return commercants;
}
public void setCommercants(List<Commercant> commercants) {
this.commercants = commercants;
}
} |
lorsque j'ajoute type=json au result success
<result name="success" type="json">/JSP/menu_order/order_distributeur/recherche/achatfinddetail.jsp</result>
je reçois cette erreur
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
org.apache.struts2.json.JSONWriter.write(JSONWriter.java:99)
org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112)
org.apache.struts2.json.JSONResult.execute(JSONResult.java:198)
s'il vous plait aidez-moi?
Partager