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 :

calendrier dans une page JSP


Sujet :

Servlets/JSP Java

  1. #1
    Membre éclairé
    Inscrit en
    Août 2010
    Messages
    416
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 416
    Points : 828
    Points
    828
    Par défaut calendrier dans une page JSP
    j'aimerai integrer un calendrier dans une page JSP, j'ai essayé un js calendar mais ca n'a pas marcher, voici le code javascript
    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
    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    <script type="text/javascript">
     
    var oldLink = null;
    // code to change the active stylesheet
    function setActiveStyleSheet(link, title) {
      var i, a, main;
      for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
        if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
          a.disabled = true;
          if(a.getAttribute("title") == title) a.disabled = false;
        }
      }
      if (oldLink) oldLink.style.fontWeight = 'normal';
      oldLink = link;
      link.style.fontWeight = 'bold';
      return false;
    }
     
    // This function gets called when the end-user clicks on some date.
    function selected(cal, date) {
      cal.sel.value = date; // just update the date in the input field.
      if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
        // if we add this call we close the calendar on single-click.
        // just to exemplify both cases, we are using this only for the 1st
        // and the 3rd field, while 2nd and 4th will still require double-click.
        cal.callCloseHandler();
    }
     
    // And this gets called when the end-user clicks on the _selected_ date,
    // or clicks on the "Close" button.  It just hides the calendar without
    // destroying it.
    function closeHandler(cal) {
      cal.hide();                        // hide the calendar
    //  cal.destroy();
      _dynarch_popupCalendar = null;
    }
     
    // This function shows the calendar under the element having the given id.
    // It takes care of catching "mousedown" signals on document and hiding the
    // calendar if the click was outside.
    function showCalendar(id, format, showsTime, showsOtherMonths) {
      var el = document.getElementById(id);
      if (_dynarch_popupCalendar != null) {
        // we already have some calendar created
        _dynarch_popupCalendar.hide();                 // so we hide it first.
      } else {
        // first-time call, create the calendar.
        var cal = new Calendar(1, null, selected, closeHandler);
        // uncomment the following line to hide the week numbers
        // cal.weekNumbers = false;
        if (typeof showsTime == "string") {
          cal.showsTime = true;
          cal.time24 = (showsTime == "24");
        }
        if (showsOtherMonths) {
          cal.showsOtherMonths = true;
        }
        _dynarch_popupCalendar = cal;                  // remember it in the global var
        cal.setRange(1900, 2070);        // min/max year allowed.
        cal.create();
      }
      _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
      _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
      _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
     
      // the reference element that we pass to showAtElement is the button that
      // triggers the calendar.  In this example we align the calendar bottom-right
      // to the button.
      _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
     
      return false;
    }
     
    var MINUTE = 60 * 1000;
    var HOUR = 60 * MINUTE;
    var DAY = 24 * HOUR;
    var WEEK = 7 * DAY;
     
    // If this handler returns true then the "date" given as
    // parameter will be disabled.  In this example we enable
    // only days within a range of 10 days from the current
    // date.
    // You can use the functions date.getFullYear() -- returns the year
    // as 4 digit number, date.getMonth() -- returns the month as 0..11,
    // and date.getDate() -- returns the date of the month as 1..31, to
    // make heavy calculations here.  However, beware that this function
    // should be very fast, as it is called for each day in a month when
    // the calendar is (re)constructed.
    function isDisabled(date) {
      var today = new Date();
      return (Math.abs(date.getTime()) / DAY) > 10;
    }
     
    function flatSelected(cal, date) {
      var el = document.getElementById("preview");
      el.innerHTML = date;
    }
     
    function showFlatCalendar() {
      var parent = document.getElementById("display");
     
      // construct a calendar giving only the "selected" handler.
      var cal = new Calendar(0, null, flatSelected);
     
      // hide week numbers
      cal.weekNumbers = false;
     
      // We want some dates to be disabled; see function isDisabled above
      cal.setDisabledHandler(isDisabled);
      cal.setDateFormat("%A, %B %e");
     
      // this call must be the last as it might use data initialized above; if
      // we specify a parent, as opposite to the "showCalendar" function above,
      // then we create a flat calendar -- not popup.  Hidden, though, but...
      cal.create(parent);
     
      // ... we can show it here.
      cal.show();
    }
    </script>
    et mon boutton :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <input type="reset" value=" ... "
    onclick="return showCalendar('sel1', '%Y-%m-%d ', '24', true);">
    c'est un exemple que j'ai trouvé sur le net, mais bon il marche pas...
    quand je click rien ne s'affiche
    Sinon si qqu'un a une autre proposition, vous etes les bienvenus

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    165
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 165
    Points : 205
    Points
    205
    Par défaut
    Salut,

    J'ai utilisé la même librairie, j'ai juste été sur cette page http://www.dynarch.com/projects/calendar/ et jeter un coup d'oeil au code source (il y a un calendrier d'affiché sur cette page).
    Il me semble que ça se fait en 3 ou 4 lignes, donc beaucoup plus simple que ce que tu as fait...

  3. #3
    Membre éclairé
    Inscrit en
    Août 2010
    Messages
    416
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 416
    Points : 828
    Points
    828
    Par défaut
    Merci je pense que c'est plus simple

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Insertion calendrier JQuery/JS dans une page JSP
    Par Viish dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 08/08/2011, 18h54
  2. Calendrier dans une page JSP
    Par ArN0.VdB dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 07/05/2008, 14h46
  3. [Sécurité] comment récupérer le subject dans une page jsp?
    Par lalakers dans le forum Servlets/JSP
    Réponses: 13
    Dernier message: 13/07/2005, 11h42
  4. [XML][XSL][Mozilla Firefox] Integraton dans une page JSP
    Par BANATACH dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 05/08/2004, 14h46
  5. [Debutant(e)]Appel d'une servlet dans une page jsp
    Par kouadjalain dans le forum Servlets/JSP
    Réponses: 5
    Dernier message: 20/07/2004, 15h02

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