2013-04-12 64 views
0

我想將fuelUx wizard包含到我的jsf/java項目中。不過,我struggeling到組件轉換到JSF:Twitter Bootstrap和Jsf - 如何集成Fuel UX wizard.js

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html 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:p="http://primefaces.prime.com.tr/ui"> 

<h:head> 
    <title>Title</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
    <meta name="description" content="" /> 
    <meta name="author" content="" /> 

    <!-- Le styles --> 
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" /> 
    <link href="css/bootstrap-responsive.css" rel="stylesheet" 
     type="text/css" /> 
    <link href="css/override.css" rel="stylesheet" type="text/css" /> 
    <link href="dist/css/fuelux.css" rel="stylesheet" type="text/css" /> 
    <link href="dist/css/fuelux-responsive.css" rel="stylesheet" 
     type="text/css" /> 
    <link href="dist/css/fuelux.min.css" rel="stylesheet" type="text/css" /> 
    <link href="dist/css/fuelux-responsive.min.css" rel="stylesheet" 
     type="text/css" /> 
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> 
    <!--[if lt IE 9]> 
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
<![endif]--> 

    <!-- Le fav and touch icons 
<link rel="shortcut icon" href="../assets/ico/favicon.ico"> 
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"> 
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"> 
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png"> 
--> 

    <h:outputScript name="js/require.js" /> 
    <script> 
//<![CDATA[ 
     requirejs.config({ 
      paths: { 
       'jquery': 'lib/jquery', 
       'underscore': 'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min', 
       'bootstrap': 'lib/bootstrap/js', 
       'fuelux': 'src' 
      } 
     }); 

     require(['jquery', 'sample/data', 'sample/datasource', 'sample/datasourceTree', 'fuelux/all'], function ($, sampleData, StaticDataSource, DataSourceTree) { 

      // WIZARD 
      $('#MyWizard').on('change', function(e, data) { 
       console.log('change'); 
       if(data.step===3 && data.direction==='next') { 
        // return e.preventDefault(); 
       } 
      }); 
      $('#MyWizard').on('changed', function(e, data) { 
       console.log('changed'); 
      }); 
      $('#MyWizard').on('finished', function(e, data) { 
       console.log('finished'); 
      }); 
      $('#btnWizardPrev').on('click', function() { 
       $('#MyWizard').wizard('previous'); 
      }); 
      $('#btnWizardNext').on('click', function() { 
       $('#MyWizard').wizard('next','foo'); 
      }); 
      $('#btnWizardStep').on('click', function() { 
       var item = $('#MyWizard').wizard('selectedItem'); 
       console.log(item.step); 
      }); 
      $('#MyWizard').on('stepclick', function(e, data) { 
       console.log('step' + data.step + ' clicked'); 
       if(data.step===1) { 
        // return e.preventDefault(); 
       } 
      }); 

     }); 
     //]]> 
    </script> 

</h:head> 
<h:body> 

    <div class="container"> 

     <!-- WIZARD --> 
     <div> 
      <div id="MyWizard" class="wizard"> 
       <ul class="steps"> 
        <li data-target="#step1" class="active"><span 
         class="badge badge-info">1</span>Step 1<span class="chevron"></span></li> 
        <li data-target="#step2"><span class="badge">2</span>Step 2<span 
         class="chevron"></span></li> 
        <li data-target="#step3"><span class="badge">3</span>Step 3<span 
         class="chevron"></span></li> 
        <li data-target="#step4"><span class="badge">4</span>Step 4<span 
         class="chevron"></span></li> 
        <li data-target="#step5"><span class="badge">5</span>Step 5<span 
         class="chevron"></span></li> 
       </ul> 
       <div class="actions"> 
        <button class="btn btn-mini btn-prev"> 
         <i class="icon-arrow-left"></i>Prev 
        </button> 
        <button class="btn btn-mini btn-next" data-last="Finish"> 
         Next<i class="icon-arrow-right"></i> 
        </button> 
       </div> 
      </div> 
      <div class="step-content"> 
       <div class="step-pane active" id="step1">This is step 1</div> 
       <div class="step-pane" id="step2">This is step 2</div> 
       <div class="step-pane" id="step3">This is step 3</div> 
       <div class="step-pane" id="step4">This is step 4</div> 
       <div class="step-pane" id="step5">This is step 5</div> 
      </div> 

      <h:button type="button" class="btn btn-mini" id="btnWizardPrev" 
       value="prev" /> 
      <h:button type="button" class="btn btn-mini" id="btnWizardNext" 
       value="next" /> 
      <h:button type="button" class="btn btn-mini" id="btnWizardStep" 
       value="current step" /> 
     </div> 

    </div> 

    <!--/.fluid-container--> 

    <!-- Le javascript 
================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <h:outputScript name="js/jquery-1.7.2.min.js" /> 
    <h:outputScript name="js/bootstrap.min.js" /> 
    <h:outputScript name="js/jquery.dataTables.min.js" /> 
    <h:outputScript name="js/bootstrap.js" /> 


</h:body> 
</html> 

當我測試的組件明確的html頁面上,內部消除JSF,我看到了,我必須包括使其工作:

<html lang="en" class="fuelux"> 

但是,我認爲那不可能在jsf中。因此,如何在jsf中實現組件?我很感謝你的回答!

回答

1

如果您無法在您的標記該類,你可以嘗試做使用jQuery如下:

$('html').addClass('fuelux');