1

Faces-config.xml が、Controller クラスのインライン アノテーション ViewScoped を RequestScoped でオーバーライドしていたことが判明しました。それを修正し、問題を解決したようです。


この質問には答えがありません 。commandButton/commandLink/ajax アクション/リスナー メソッドが呼び出されていないか、入力値が更新されていません。そうであると思われる場合は、primefaces fluidGrid 拡張機能を使用して実際の修正/例を提供してください。

私はprimefaces ui exension fluidGridを使用しています: http://fractalsoft.net/primeext-showcase-mojarra/sections/fluidgrid/dynamic.jsf

profileController.testControl() を呼び出すことができないようです。commandButton を fluidGrid の外側に配置すると、正常に動作しますが、グリッド内では動作しません。何か案は?

Bean を @ViewScoped に変更してテストしましたが、ネストされたフォームなどはありません。

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions"
    xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
    <composite:attribute name="resultList" />
</composite:interface>

<composite:implementation>

<h:form id="form1" rendered="true">

    <!-- Grid -->
    <pe:fluidGrid value="#{resultList}" var="showvar" hGutter="20" rowKeyVar="rowKey" fitWidth="true" hasImages="true" rendered="true" >        
        <pe:fluidGridItem rendered="true" >
          <p:panel id="seriesPanel"  rendered="#{showvar.isSeries()}"></p:panel>                    
          <p:panel id="episodePanel" rendered="#{!showvar.isSeries()}" >

           <p:commandButton value="click me" action="#{profileController.testControl()}"/>

           <!-- another button attempt that doesn't work -->
           <p:commandButton process="fluidGrid" value="click me again" ajax="false" actionListener="#{profileController.testControlEvent()}" />

          </p:panel>                             
        </pe:fluidGridItem>         
    </pe:fluidGrid>

</h:form>

</composite:implementation>
</html>

//Tried with  @ViewScoped as well
@Model
public class ProfileController {
    public void testControl(){
        log.info("---------------------------------------");
        log.info("TEST CONTROL CLICKED");
        log.info("---------------------------------------");
    }

    public void testControlEvent(ActionEvent actionEvent){
        log.info("---------------------------------------");
        log.info("TEST CONTROL CLICKED");
        log.info("---------------------------------------");
    }
}
4

3 に答える 3

1

fluidGrid内にコマンドボタンを配置する簡単な例を試してみましたが、ここで機能します。

XHTML ファイル

<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:pe="http://primefaces.org/ui/extensions"
    xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>


    <h:form id="login">
        <pe:fluidGrid value="#{tBean.images}" var="showvar" hGutter="20"
            rowKeyVar="rowKey" fitWidth="true" hasImages="true" rendered="true">
            <pe:fluidGridItem rendered="true">


                <p:commandButton value="click me" action="#{tBean.doAction}" />

            </pe:fluidGridItem>
        </pe:fluidGrid>
    </h:form>

</h:body>
</html>

ManagedBean コード

package bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.extensions.model.fluidgrid.FluidGridItem;

@ManagedBean(name = "tBean")
@ViewScoped
public class TestBean implements Serializable{

    private List<FluidGridItem> images;

    @PostConstruct
    protected void initialize() {
        images = new ArrayList<FluidGridItem>();

        for (int j = 0; j < 3; j++) {
            for (int i = 1; i <= 10; i++) {
                images.add(new FluidGridItem("i" + 1));
            }
        }
    }

    public void doAction() {

        System.out.println("Im doing action");
    }

    public List<FluidGridItem> getImages() {
        return images;
    }
}

上記を試して、それがうまくいくかどうかを確認してください。機能する場合は、実装で使用してみてください。

于 2014-05-17T12:06:51.007 に答える
0

フォームを更新する必要があります。ページにボタン update=":form1:fluidGrid" を追加すると思います。作業が ajax を true にする場合、このような問題を解決するのに役立ちました。

于 2014-05-16T17:07:41.027 に答える