2011-06-17 12 views
2

私は以下のxhtmlファイルを持っています:rich:calendarと私はいくつかの日を無効にしようとしていますusing this example。しかし、javascript関数は呼び出されません。どうしてか分かりません。<rich:calendar>クライアント側で週末を無効にする

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html ... > 

<f:view locale="en"> 
    <script type="text/javascript"> 
    function isDayEnabled(day){ 
     var date = new Date(day.date); 
     return (date.getDay() == 6); 
    } 
    function getDisabledStyle(day){ 
     if (!isDayEnabled(day)) return 'rich-calendar-boundary-dates disabledDay'; 
    } 
    </script> 

<h:head> 
<style type="text/css"> 
    .disabledDay { background-color:gray; } 
</style> 
</h:head> 

<h:body> 
<div id="workspace"> 
    <h:form id="form"> 
    <h:outputText value="Datum: " /> 
    <rich:calendar mode="ajax" id="calendar" 
    isDayEnabled="isDayEnabled();" dayStyleClass="getDisabledStyle();">     
    </rich:calendar> 
.... 

お手伝いできますか?

答えて

5

ショーケースの例に示すように、の名前をとする必要があります。かっこを削除します。

<rich:calendar mode="ajax" id="calendar" 
    isDayEnabled="isDayEnabled" dayStyleClass="getDisabledStyle"> 

それとも、RichFacesの4.0を使用して実際ているとき、あなたはdifferent showcase siteをチェックする必要があります。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich"> 
    <h:outputStylesheet> 
     .everyThirdDay { 
      background-color: gray; 
     } 

     .weekendBold { 
      font-weight: bold; 
      font-style: italic; 
     } 
    </h:outputStylesheet> 
    <h:outputScript> 
     var curDt = new Date(); 
     function disablementFunction(day){ 
      if (day.isWeekend) return false; 
      if (curDt==undefined){ 
       curDt = day.date.getDate(); 
      } 
      if (curDt.getTime() - day.date.getTime() &lt; 0) return true; else return false; 
     } 
     function disabledClassesProv(day){ 
      if (curDt.getTime() - day.date.getTime() &gt;= 0) return 'rf-cal-boundary-day'; 
      var res = ''; 
      if (day.isWeekend) res+='weekendBold '; 
      if (day.day%3==0) res+='everyThirdDay'; 
      return res; 
     } 
    </h:outputScript> 
    <rich:calendar dayDisableFunction="disablementFunction" 
     dayClassFunction="disabledClassesProv" boundaryDatesMode="scroll" /> 
</ui:composition> 

属性はdayDisableFunctiondayClassFunctionに名称​​変更されています。

+0

ありがとうございます。この例も以前にも見つかりました。しかし、私は単にそれをxhtmlにコピーして起動しても動作しません。私はカレンダーボタンをクリックすることができません、それは無効です.. – gaffcz

+0

RF 3.3または4.0を使用していますか?そして、これはインクルードテンプレート( ''!を見てください)が、マスターテンプレートの中に ''で含まれていなければならないことを認識しています。これは ''自動的に追加されますか? – BalusC

+0

RF4.0。ああ、私はそれを知らなかった、私はまだHTMLタグを使用している:(私はそれをより深く見てみるよありがとう! – gaffcz

関連する問題