0

我有个问题。在我的项目中,我使用 MaterialPrime lib 和 Material Design Lite。在我的登录页面上,我使用 m:button 元素提交表单(据我所知,Ajax 请求发生在这里)。然后重定向到包含资源的面板页面,但我收到 PrimeFaces.ajax 错误(ajax 属性为空)。但是使用 h:comandButton 可以解决这个问题。有什么解决办法吗?也许 m:button 的属性不做 ajax 请求,或者另一个按钮标签?我需要这个按钮来设置页面样式。这是登录页面。

<?xml version="1.0" encoding="UTF-8"?>
<!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:mp="http://primefaces.org/ui/material"
  xmlns:p="http://primefaces.org/ui">
<h:head>
  <title>Welcome to Joy</title>
  <h:outputStylesheet library="css" name="general.css" />
</h:head>
<h:body>
  <ui:debug hotkey="x" />
  <div class="center">
    <h:form prependId="true">
      <div class="row">
        <mp:input icon="mdi-action-account-circle" id="login_field" label="Login" value="#{userBean.dtoUser.login}">
          <f:validator validatorId="notNullValidator" />
          <f:validateBean binding="#{loginValidator}" />
          <f:attribute name="passwordValue" value="#{passwordValue}" />
        </mp:input>
        <mp:input icon="mdi-action-https" id="password_field" label="Password" value="#{userBean.dtoUser.password}"
          binding="#{passwordValue}" required="true" />          
        <mp:button icon="mdi-content-forward" value="Login" action="#{userBean.login}" />        
        <mp:button immediate="true" icon="mdi-social-person-add" value="Sign Up" flat="true" action="registration" />
      </div>
    </h:form>
  </div>
</h:body>
</html>

这是接受登录后的页面

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core" xmlns:mp="http://primefaces.org/ui/material" xmlns:p="http://primefaces.org/ui"
  xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
<h:head>
  <title><ui:insert name="title" /></title>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="description" content="A front-end template that helps you build fast, modern mobile web apps." />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes" />
  <link rel="icon" sizes="192x192" href="images/touch/chrome-touch-icon-192x192.png" />
  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="apple-mobile-web-app-title" content="Material Design Lite" />
  <link rel="apple-touch-icon-precomposed" href="apple-touch-icon-precomposed.png" />
  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="images/touch/ms-touch-icon-144x144-precomposed.png" />
  <meta name="msapplication-TileColor" content="#3372DF" />
  <!-- SEO: If your mobile URL is different from the desktop URL, add a canonical link to the desktop page https://developers.google.com/webmasters/smartphone-sites/feature-phones -->
  <!--
    <link rel="canonical" href="http://www.example.com/">
    -->
  <link href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en"
    rel="stylesheet" />
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
  <h:outputStylesheet library="css" name="material.min.css" />
  <h:outputStylesheet library="css" name="styles.css" />
  <h:outputScript library="js" name="material.min.js" />
</h:head>
<h:body>
  <div class="demo-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">

    <div class="demo-drawer mdl-layout__drawer mdl-color--blue-grey-900 mdl-color-text--blue-grey-50">
    <header class="demo-drawer-header">
      <h:graphicImage name="images/user.jpg" styleClass="demo-avatar" />
      <div class="demo-avatar-dropdown">
        <span><h:outputText value="#{userBean.user.login}" /> </span>
        <div class="mdl-layout-spacer"></div>
        <button id="accbtn" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon">
          <i class="material-icons" role="presentation">arrow_drop_down</i> <span class="visuallyhidden">Accounts</span>
        </button>
        <ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="accbtn">
          <li class="mdl-menu__item">hello@example.com</li>
          <li class="mdl-menu__item">info@example.com</li>
          <li class="mdl-menu__item"><i class="material-icons">add</i>Add another account...</li>
        </ul>
      </div>
    </header>

    </div>
    <main class="mdl-layout__content mdl-color--grey-100">
      <div class="mdl-grid demo-content">
        <div class="demo-charts mdl-color--white mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-grid">
          <svg fill="currentColor" width="200px" height="200px" viewBox="0 0 1 1"
            class="demo-chart mdl-cell mdl-cell--4-col mdl-cell--3-col-desktop">
              <use xlink:href="#piechart" mask="url(#piemask)" /> -->
              <text x="0.5" y="0.5" font-family="Roboto" font-size="0.3" fill="#888" text-anchor="middle" dy="0.1">82<tspan
              font-size="0.2" dy="-0.07">%</tspan></text>
            </svg>
          <svg fill="currentColor" width="200px" height="200px" viewBox="0 0 1 1"
            class="demo-chart mdl-cell mdl-cell--4-col mdl-cell--3-col-desktop">
              <use xlink:href="#piechart" mask="url(#piemask)" />
              <text x="0.5" y="0.5" font-family="Roboto" font-size="0.3" fill="#888" text-anchor="middle" dy="0.1">82<tspan
              dy="-0.07" font-size="0.2">%</tspan></text>
            </svg>
          <svg fill="currentColor" width="200px" height="200px" viewBox="0 0 1 1"
            class="demo-chart mdl-cell mdl-cell--4-col mdl-cell--3-col-desktop">
              <use xlink:href="#piechart" mask="url(#piemask)" />
              <text x="0.5" y="0.5" font-family="Roboto" font-size="0.3" fill="#888" text-anchor="middle" dy="0.1">82<tspan
              dy="-0.07" font-size="0.2">%</tspan></text>
            </svg>
          <svg fill="currentColor" width="200px" height="200px" viewBox="0 0 1 1"
            class="demo-chart mdl-cell mdl-cell--4-col mdl-cell--3-col-desktop">
              <use xlink:href="#piechart" mask="url(#piemask)" />
              <text x="0.5" y="0.5" font-family="Roboto" font-size="0.3" fill="#888" text-anchor="middle" dy="0.1">82<tspan
              dy="-0.07" font-size="0.2">%</tspan></text>
            </svg>
        </div>
        <div class="demo-graphs mdl-shadow--2dp mdl-color--white mdl-cell mdl-cell--8-col">
          <svg fill="currentColor" viewBox="0 0 500 250" class="demo-graph">
              <use xlink:href="#chart" />
            </svg>
          <svg fill="currentColor" viewBox="0 0 500 250" class="demo-graph">
              <use xlink:href="#chart" />
            </svg>
        </div>
        <div class="demo-cards mdl-cell mdl-cell--4-col mdl-cell--8-col-tablet mdl-grid mdl-grid--no-spacing">
          <div class="demo-updates mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--12-col-desktop">
            <div class="mdl-card__title mdl-card--expand mdl-color--teal-300">
              <h2 class="mdl-card__title-text">Updates</h2>
            </div>
            <div class="mdl-card__supporting-text mdl-color-text--grey-600">Non dolore elit adipisicing ea reprehenderit consectetur
              culpa.</div>
            <div class="mdl-card__actions mdl-card--border">
              <a href="#" class="mdl-button mdl-js-button mdl-js-ripple-effect">Read More</a>
            </div>
          </div>
          <div class="demo-separator mdl-cell--1-col"></div>
          <div
            class="demo-options mdl-card mdl-color--deep-purple-500 mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--3-col-tablet mdl-cell--12-col-desktop">
            <div class="mdl-card__supporting-text mdl-color-text--blue-grey-50">
              <h3>View options</h3>
              <ul>
                <li><label for="chkbox1" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"> <input type="checkbox"
                    id="chkbox1" class="mdl-checkbox__input" /> <span class="mdl-checkbox__label">Click per object</span>
                </label></li>
                <li><label for="chkbox2" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"> <input type="checkbox"
                    id="chkbox2" class="mdl-checkbox__input" /> <span class="mdl-checkbox__label">Views per object</span>
                </label></li>
                <li><label for="chkbox3" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"> <input type="checkbox"
                    id="chkbox3" class="mdl-checkbox__input" /> <span class="mdl-checkbox__label">Objects selected</span>
                </label></li>
                <li><label for="chkbox4" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect"> <input type="checkbox"
                    id="chkbox4" class="mdl-checkbox__input" /> <span class="mdl-checkbox__label">Objects viewed</span>
                </label></li>
              </ul>
            </div>
            <div class="mdl-card__actions mdl-card--border">
              <a href="#" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-color-text--blue-grey-50">Change location</a>
              <div class="mdl-layout-spacer"></div>
              <i class="material-icons">location_on</i>
            </div>
          </div>
        </div>
      </div>
    </main>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
      style="position: fixed; left: -1000px; height: -1000px;">
        <defs>
          <mask id="piemask" maskContentUnits="objectBoundingBox">
            <circle cx="0.5" cy="0.5" r="0.49" fill="white" />
            <circle cx="0.5" cy="0.5" r="0.40" fill="black" />
          </mask>
          <g id="piechart">
            <circle cx="0.5" cy="0.5" r="0.5" />
            <path d="M 0.5 0.5 0.5 0 A 0.5 0.5 0 0 1 0.95 0.28 z" stroke="none" fill="rgba(255, 255, 255, 0.75)" />
          </g>
        </defs>
      </svg>
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 250"
      style="position: fixed; left: -1000px; height: -1000px;">
        <defs>
          <g id="chart">
            <g id="Gridlines">
              <line fill="#888888" stroke="#888888" stroke-miterlimit="10" x1="0" y1="27.3" x2="468.3" y2="27.3" />
              <line fill="#888888" stroke="#888888" stroke-miterlimit="10" x1="0" y1="66.7" x2="468.3" y2="66.7" />
              <line fill="#888888" stroke="#888888" stroke-miterlimit="10" x1="0" y1="105.3" x2="468.3" y2="105.3" />
              <line fill="#888888" stroke="#888888" stroke-miterlimit="10" x1="0" y1="144.7" x2="468.3" y2="144.7" />
              <line fill="#888888" stroke="#888888" stroke-miterlimit="10" x1="0" y1="184.3" x2="468.3" y2="184.3" />
            </g>
            <g id="Numbers">
              <text transform="matrix(1 0 0 1 485 29.3333)" fill="#888888" font-family="'Roboto'" font-size="9">500</text>
              <text transform="matrix(1 0 0 1 485 69)" fill="#888888" font-family="'Roboto'" font-size="9">400</text>
              <text transform="matrix(1 0 0 1 485 109.3333)" fill="#888888" font-family="'Roboto'" font-size="9">300</text>
              <text transform="matrix(1 0 0 1 485 149)" fill="#888888" font-family="'Roboto'" font-size="9">200</text>
              <text transform="matrix(1 0 0 1 485 188.3333)" fill="#888888" font-family="'Roboto'" font-size="9">100</text>
              <text transform="matrix(1 0 0 1 0 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">1</text>
              <text transform="matrix(1 0 0 1 78 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">2</text>
              <text transform="matrix(1 0 0 1 154.6667 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">3</text>
              <text transform="matrix(1 0 0 1 232.1667 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">4</text>
              <text transform="matrix(1 0 0 1 309 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">5</text>
              <text transform="matrix(1 0 0 1 386.6667 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">6</text>
              <text transform="matrix(1 0 0 1 464.3333 249.0003)" fill="#888888" font-family="'Roboto'" font-size="9">7</text>
            </g>
            <g id="Layer_5">
              <polygon opacity="0.36" stroke-miterlimit="10"
        points="0,223.3 48,138.5 154.7,169 211,88.5
              294.5,80.5 380,165.2 437,75.5 469.5,223.3     " />
            </g>
            <g id="Layer_4">
              <polygon stroke-miterlimit="10"
        points="469.3,222.7 1,222.7 48.7,166.7 155.7,188.3 212,132.7
              296.7,128 380.7,184.3 436.7,125   " />
            </g>
          </g>
        </defs>
      </svg>
  </div>
</h:body>
</html>
4

0 回答 0