IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

struts2 et jsp


Sujet :

Servlets/JSP Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 1
    Par défaut struts2 et jsp
    hey,

    am still a beginer in struts2 and jsp, and i realy need some help

    i want to get some data from the data base and view it in a jsp page.
    for the moment am just creating a list in the action class to finish the view part am using the <s:iterator> to create the <td> of my table and here is what i am doing:
    the CampaignData.jsp:

    <form id="CampaignForm" action="campaignDataAction.action" method="post">
    <table border="0">
    <tr>
    <th>NOM</th>
    <th>ID</th>
    <th>Treatment_Code</th>
    <th>Date_Creation</th>
    <th>Date_Prevue_Envoi</th>
    <th>Date_Generation</th>
    <th>Date_Envoi</th>
    <th>Historisation_Cible</th>
    <th>Historisation_Temoin</th>
    <th>canal</th>
    <th>test</th>
    <th>status</th>
    </tr>
    <s:iterator value="campaigns" status="campaign">
    <tr>
    <td><s:property value="nom" /></td>
    <td><s:property value="id" /></td>
    <td><s:property value="treatmentCode" /></td>
    <td><s:property value="dateCreation" /></td>
    <td><s:property value="datePrevueEnvoi" /></td>
    <td><s:property value="dateGeneration" /></td>
    <td><s:property value="dateEnvoi" /></td>
    <td><s:property value="historisationCible" /></td>
    <td><s:property value="historisationTemoin" /></td>
    <td><s:property value="canal" /></td>
    <td><s:property value="test" /></td>
    <td><s:property value="status" /></td>
    </tr>
    </s:iterator>
    </table>
    </form>

    the CamapaignDataAction.java:

    package action;

    import java.util.ArrayList;
    import java.util.List;

    import model.CampaignInfo;

    import com.opensymphony.xwork2.ActionSupport;


    public class CampaignDataAction
    extends ActionSupport
    {
    /**
    *
    */
    private static final long serialVersionUID = 1L;

    private CampaignInfo campaign;

    private CampaignInfo campaign1;

    private List<CampaignInfo> campaigns;

    public String execute()
    {
    campaigns = new ArrayList<CampaignInfo>();
    campaign = new CampaignInfo();
    campaign.setCanal( "test" );
    campaign.setDateCreation( "test" );
    campaign.setDateEnvoi( "test" );
    campaign.setDateGeneration( "test" );
    campaign.setDatePrevueEnvoi( "test" );
    campaign.setHistorisationCible( "test" );
    campaign.setHistorisationTemoin( "test" );
    campaign.setId( "test" );
    campaign.setNom( "test" );
    campaigns.add( campaign );
    campaign1 = new CampaignInfo();
    campaign1.setCanal( "test" );
    campaign1.setDateCreation( "test" );
    campaign1.setDateEnvoi( "test" );
    campaign1.setDateGeneration( "test" );
    campaign1.setDatePrevueEnvoi( "test" );
    campaign1.setHistorisationCible( "test" );
    campaign1.setHistorisationTemoin( "test" );
    campaign1.setId( "test" );
    campaign1.setNom( "test" );
    campaigns.add( campaign1 );
    return "success";

    }

    /**
    * @return the campaign
    */
    public CampaignInfo getCampaign()
    {
    return campaign;
    }

    /**
    * @param campaign the campaign to set
    */
    public void setCampaign( CampaignInfo campaign )
    {
    this.campaign = campaign;
    }

    /**
    * @return the campaign1
    */
    public CampaignInfo getCampaign1()
    {
    return campaign1;
    }

    /**
    * @param campaign1 the campaign1 to set
    */
    public void setCampaign1( CampaignInfo campaign1 )
    {
    this.campaign1 = campaign1;
    }

    /**
    * @return the campaigns
    */
    public List<CampaignInfo> getCampaigns()
    {
    return campaigns;
    }

    /**
    * @param campaigns the campaigns to set
    */
    public void setCampaigns( List<CampaignInfo> campaigns )
    {
    this.campaigns = campaigns;
    }

    }

    the struts.xml:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

    <struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.custom.i18n.resources" value="ApplicationResources" />

    <package name="default" extends="struts-default" namespace="/">
    <result-types>
    <result-type name="tiles"
    class="org.apache.struts2.views.tiles.TilesResult" />
    </result-types>
    <action name="login" class="action.LoginAction">
    <result name="success" type="tiles">/welcome.tiles</result>
    <result name="error">Login.jsp</result>
    </action>
    <action name="customer" class="action.CustomerAction">
    <result name="success" type="tiles">/customer.success.tiles</result>
    <result name="input" type="tiles">/customer.tiles</result>
    </action>
    <action name="iteratorTag" class="action.iteratorTag">
    <result>/welcome.tiles</result>
    </action>
    <action name="campaignDataAction" class="action.CampaignDataAction">
    <result name="success" type="tiles">/welcome.tiles</result>
    </action>
    <action name="customer-form">
    <result name="success" type="tiles">/customer.tiles</result>
    </action>
    </package>
    </struts>

    its somehow urgent and i need to finish this part so that i can work on the css and other parts of my apli
    thanks in return.

  2. #2
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Par défaut
    Your question needs more informations or more details, we don't know your database structure, or persistent framework that you use in your application.

Discussions similaires

  1. [Plugin] jtip.js avec struts2 et page JSP
    Par luchet dans le forum jQuery
    Réponses: 6
    Dernier message: 01/07/2015, 14h27
  2. Réponses: 2
    Dernier message: 03/06/2014, 17h23
  3. Réponses: 0
    Dernier message: 18/07/2012, 15h31
  4. MethodFailedException JSP Struts2
    Par Kigou dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 28/06/2011, 11h49
  5. [JSP/Servlet] Outils pour developper?
    Par BenoitM dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 04/05/2004, 11h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo