remplir une collection à partir d'une autre collection
bonjour tous le monde
j'ai un vue qui contient 2collections
Code:
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 75
|
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>activation</title>
<layout:skin includeScript="true"/>
<script>
function setHidden(value){document.activationpostForm.hidden.value=value;}
</script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<layout:form action="/preactivpost.do" method="post">
<layout:text property="hidden" value="default" mode="H,H,H"></layout:text>
<layout:collection name="activationpostForm" property="postpaid" styleClass="SCROLL" styleClass="FORM" width="1110" height="350">
<layout:collectionItem title="ARTICLE" property="art"></layout:collectionItem>
<layout:collectionItem title="PROFIL" property="prof" sortable="true"></layout:collectionItem>
<layout:collectionItem title="SERIAL_START" property="start" sortable="true"></layout:collectionItem>
<layout:collectionItem title="SERIAL_END" property="end" sortable="true"></layout:collectionItem>
<layout:collectionItem title="HLR" property="hlr" sortable="true"></layout:collectionItem>
<layout:collectionItem title="ACTIVATION" property="activ" sortable="true"></layout:collectionItem>
<layout:collectionItem title="PACKAGING" property="pack" sortable="true"></layout:collectionItem>
<layout:collectionItem title="QTE" property="qte" sortable="true"></layout:collectionItem>
<layout:collectionItem title="AJOUTER" property="ajouter" action="/preactive.do?hidden=afficher" paramId="article,profil,s_str,s_end,qute" paramProperty="article,profil,s_str,s_end,qute">
<center>+</center>
</layout:collectionItem>
</layout:collection>
</layout:form>
<layout:space></layout:space>
<layout:form action="/preactive.do" method="post">
<logic:notEmpty property="postpaid2" name="activationpostForm">
<logic:present parameter="hidden" scope="request">
<logic:equal value="afficher" parameter="hidden" scope="request">
<logic:present name="activationpostForm">
<layout:collection name="activationpostForm" property="postpaid2" styleClass="SCROLL" styleClass="FORM" width="900" height="100">
<layout:collectionItem title="ARTICLE" property="aa"></layout:collectionItem>
<layout:collectionItem title="PROFIL" property="pp" sortable="true"></layout:collectionItem>
<layout:collectionItem title="SERIAL_START" property="st" sortable="true"></layout:collectionItem>
<layout:collectionItem title="SERIAL_END" property="se" sortable="true"></layout:collectionItem>
<layout:collectionItem title="QTE" property="qt" sortable="true"></layout:collectionItem>
</layout:collection>
</logic:present>
</logic:equal>
</logic:present>
</logic:notEmpty>
</layout:form>
</body>
</html:html> |
je veux recupérer des lignes à partir de la 1ere collection et les affiche dans le 2eme collection au fur et a mesure
voila le code de l'action
Code:
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
|
public class PreactiveAction extends DispatchAction {
public ActionForward afficher(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActivationpostForm activationpostForm = (ActivationpostForm) form;
Preactive pre = new Preactive();
ArrayList list = new ArrayList();
ArrayList list2,list4,list3 = new ArrayList();
list2 = (ArrayList)request.getSession().getAttribute("postpaid");
activationpostForm.setPostpaid(list2);
String article = request.getParameter("article");
System.out.println(article);
String profil = request.getParameter("profil");
System.out.println(profil);
String s_str = request.getParameter("s_str");
System.out.println(s_str);
String s_end = request.getParameter("s_end");
System.out.println(s_end);
String qute = request.getParameter("qute");
System.out.println(qute);
list4 = (ArrayList)request.getSession().getAttribute("postpaid2");
activationpostForm.setPostpaid2(list4);
pre.setAa(article);
pre.setPp(profil);
pre.setQt(qute);
pre.setSe(s_end);
pre.setSt(s_str);
list4.add(pre);
for (int i=0;i<list4.size();i++)
{
Preactive ppre = (Preactive)list4.get(i);
System.out.println("aa="+ppre.getAa());
System.out.println("pp="+ppre.getPp());
System.out.println("st="+ppre.getSt());
System.out.println("se="+ppre.getSe());
System.out.println("qt="+ppre.getQt());
}
activationpostForm.setPostpaid2(list4);
request.getSession().setAttribute("postpaid2",list4);
return mapping.findForward("active");
} |
je pense que pour garder l'ancienne collection je doit la mettre dans le request avan d'ajouter une autre ligne
mais il m'affiche l'erreur
Code:
1 2
|
null pointer exception |