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

Taglibs Java Discussion :

<c:when> Test sur la taille d'un Vector


Sujet :

Taglibs Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut <c:when> Test sur la taille d'un Vector
    Bonjour,

    J'ai un petit soucis, je n'arrive pas à l'aide du tag c:when à accéder à la taille d'un Vector se trouvant dans un JavaBean.

    Donc j'ai un JavaBean (version courte)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package beans;
     
    import org.apache.log4j.Logger;
     
    import java.util.Vector;
     
    /**
     * Created by IntelliJ IDEA.
     * User: delcrst
     * Date: 12-juin-2006
     * Time: 11:35:52
     * To change this template use File | Settings | File Templates.
     */
    public class WelcomeBean implements java.io.Serializable{
     
    private Vector callInstrumentInfo;
        Logger log = Logger.getLogger(WelcomeBean.class.getName());
     
     public WelcomeBean()
        {}
     
    public Vector getCallInstrumentInfo() {
            return callInstrumentInfo;
        }
     
        public void setCallInstrumentInfo(Vector callInstrumentInfo) {
            this.callInstrumentInfo = callInstrumentInfo;
            if(callInstrumentInfo.size() > 1)
            {
                setCallCode((String)callInstrumentInfo.elementAt(1));
                setInstrumentId(((Integer)callInstrumentInfo.elementAt(0)).intValue());
                if(((Integer)callInstrumentInfo.get(2)).intValue() == 1)
                {
                    setSingle(true);
                }
                if(((Integer)callInstrumentInfo.get(3)).intValue() == 1)
                {
                    setOnlineOnly(true);
                }
                if(((Integer)callInstrumentInfo.get(4)).intValue() == 1)
                {
                    setMobCall(true);
                    log.info("The call {"+getCallId()+"} is a Mobility Call");
                }
            }
        }
     
     
    }
    Ensuite voici le bout de code que j'utilise dans ma jsp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    <c:choose>
                    <%log.info("Call instrument Info size = "+welcomeBean.getCallInstrumentInfo().size());%>
                        <c:when test="${welcomeBean.['callInstrumentInfo'].['size'] > 1}">
     
    ...............
    ..............
    .................
    Le test dans la balise c:when ne fonctionne pas. Il me retourne un ClassCastException.

    Existe-t-il une manière de tester la taille d'un Vector se trouvant dans un JavaBean sans utiliser de scriplet

    d'avance pour vos réponses

  2. #2
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Salut,


    Il faut utiliser l'opérateur EL empty : http://adiguba.developpez.com/tutori...e/jsp/el/#L1.5
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <c:when test="${empty welcomeBean['callInstrumentInfo']}">
    a++

  3. #3
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut
    dsl pourtant j'avais suivi ton tuto sur les EL

    Mais cela ne marche pas quand même.

    quand je vire le c:when et le c:otherwise du c:choose, j'ai toujours le même problème.
    Par contre si je vire le c:choose complètement alors la page s'affiche bien.

    Y a un truc que je ne comprends pas là


  4. #4
    Expert éminent
    Avatar de adiGuba
    Homme Profil pro
    Développeur Java/Web
    Inscrit en
    Avril 2002
    Messages
    13 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java/Web
    Secteur : Transports

    Informations forums :
    Inscription : Avril 2002
    Messages : 13 938
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par Stessy
    quand je vire le c:when et le c:otherwise du c:choose, j'ai toujours le même problème.
    Tu pourrais indiquer le stacktrace de l'exception ?

    a++

  5. #5
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut
    Ben je n'ai pas de stacktrace

    Pourtant j'utilise un c:catch qui englobe le c:choose

    mais je n'ai rien qui apparait à part ça

    2006-06-14 11:29:00.564 NOTIFICATION J2EE JSP0008 Unable to dispatch JSP Page :
    Exception :java.lang.ClassCastException: java.lang.String
    C'est pour cela que je poste ici. Si j'avais eu une stacktrace je pense que j'aurais su m'en sortir.
    J'ai été voir dans tous les logs de OC4J voir si il n'y aurait pas une trace, mais je n'ai rien vu.

    Je vais une fois épurer la page et retirer ce qui ne se rapporte pas aux EJB. Je vais lancer cette page dans tomcat et voir si le problème n'est pas spécifique à OC4J.

    J'ai souvent de belles surprises avec cet application server.


  6. #6
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut
    Voilà la stacktrace sous Tomcat:

    ERROR: 2006-06-14 12:29:14,814 "Servlet.service()" pour la servlet jsp a généré une exception
    org.apache.jasper.JasperException: <h3>Message d'erreurs de validation provenant du TagLibraryValidator pour c en /welcomeFaces2.jsp</h3><p>81: tag = 'when' / attribute = 'test': An error occurred while parsing custom action attribute "test" with value "${not empty welcomeBean.['callInstrumentInfo']}": Encountered "[", expected one of [<IDENTIFIER>]</p>
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:72)
    at org.apache.jasper.compiler.Validator.validateXmlView(Validator.java:1549)
    at org.apache.jasper.compiler.Validator.validate(Validator.java:1495)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

Discussions similaires

  1. [JSTL] c:when test sur un integer KO
    Par jayjaypg22 dans le forum Taglibs
    Réponses: 2
    Dernier message: 22/10/2010, 10h01
  2. test sur la taille d'une image
    Par helaaa dans le forum Images
    Réponses: 2
    Dernier message: 25/08/2009, 14h21
  3. Problème de test sur la taille des fichiers
    Par gregal dans le forum Langage
    Réponses: 7
    Dernier message: 12/12/2006, 20h57
  4. test sur fichiers[forms9i]
    Par Challenger dans le forum Forms
    Réponses: 6
    Dernier message: 14/06/2004, 17h25
  5. Test sur un champs vide
    Par PrinceMaster77 dans le forum ASP
    Réponses: 2
    Dernier message: 27/04/2004, 12h54

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