0

私は現在、WildFly 10 の JRE 8 で Mojarra 2.2.13 で rewrite-config-prettyfaces 3.4.0.Final を使用しています。ここで、pretty-config.xml ファイルを削除して、ルール ベースの RewriteConfiguration に切り替えたいと思います。これを作成し、pretty-config url-mapping をルールにマッピングすると、アプリケーションは正常に動作するように見えます。しかし、h:commandLink アクションが呼び出されなくなったことに気付きました。pretty-config.xml に戻すと正常に動作します。元に戻してください。これが RewriteConfiguration で機能しない理由はありますか?

私のクラスパスには、次の書き換え jar が含まれています。

  • rewrite-servlet-3.4.0.Final.jar
  • rewrite-config-prettyfaces-3.4.0.Final.jar (ただし、これは動作していないセットアップでは削除されます)

以下に、私のコードのスニペットをいくつか示します。

どうもありがとう!

私のかなり構成はこの構成を持っています

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

    <url-mapping id="start">
        <pattern value="/#{lang}"/>
        <view-id value="/dashboard.jsf"/>
    </url-mapping>
    <url-mapping id="download">
        <pattern value="/#{lang}/downloadReport.html"/>
        <view-id value="/downloadReport.jsf"/>
    </url-mapping>
    <url-mapping id="catalog">
        <pattern value="/#{lang}/catalogue/#{catalogName}"/>
        <view-id value="/catalogDashboard.jsf"/>
    </url-mapping>
    <url-mapping id="violations">
        <pattern value="/#{lang}/catalogue/#{catalogName}/violations"/>
        <view-id value="/violations.jsf"/>
    </url-mapping>
    <url-mapping id="distributions">
        <pattern value="/#{lang}/catalogue/#{catalogName}/distributions"/>
        <view-id value="/distributions.jsf"/>
    </url-mapping>

</pretty-config>

私の RewriteConfiguration ファイル

@RewriteConfiguration
public class ApplicationNavigationConfigurationProvider extends HttpConfigurationProvider {

    @Override
    public Configuration getConfiguration(ServletContext servletContext) {
        return ConfigurationBuilder.begin()
                .addRule(TrailingSlash.remove())
                .addRule(Join.path("/{lang}").to("/dashboard.jsf"))
                .addRule(Join.path("/{lang}/downloadReport.html").to("/downloadReport.jsf"))
                .addRule(Join.path("/{lang}/catalogue/{catalogName}").to("/catalogDashboard.jsf"))
                .addRule(Join.path("/{lang}/catalogue/{catalogName}/violations").to("/violations.jsf"))
                .addRule(Join.path("/{lang}/catalogue/{catalogName}/distributions").to("/distributions.jsf"));
    }

    @Override
    public int priority() {
        return 0;
    }
}

私の単純化した dummy.xhtml ファイルは次のようになります。

注: commandLink に関連するセクションは、実際には catalogDashboard.jsf の一部です。欠落しているダミーの書き換え規則が存在すると考えてください。

<?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://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<f:view>   
    <h:body>
        <h:outputText value="#{harvesterBean.currentRepository.name}"/>
        <h:form>
            <h:commandLink action="#{harvesterBean.updateAttachment(1)}" value="Test action invocation">
                <f:param name="catalogName" value="#{request.getParameter('catalogName')}"/>
            </h:commandLink>
        </h:form>
    </h:body>
</f:view>
</html>

commandLinkアクションを介して呼び出すメソッドを持つ私のBean

@ViewScoped
@Named
public class HarvesterBean implements Serializable  { // updated: implements Serializable 

    @Inject
    private HarvesterClientActionImpl harvesterClientAction;

    @Inject
    private CurrentCatalogBean currentCatalogBean;

    private Repository currentRepository;
    private Harvester currentHarvester;
    private Run currentRun;
    private List<RunLog> logs;
    private String selectedAttachment;

    @PostConstruct
    public void init() {
        currentRepository = harvesterClientAction.retrieveRepository(currentCatalogBean.getCurrentCatalog().getTitle());
        currentHarvester = harvesterClientAction.retrieveHarvester(currentRepository.getSourceHarvester());
        currentRun = harvesterClientAction.retrieveLastRun(currentHarvester.getId());
        logs = harvesterClientAction.retrieveRunLogs(currentHarvester.getId(), currentRun.getId());

    }

    // This method is not invoked when using the RewriteConfiguration instead of pretty-config.xml
    public void updateAttachment(long logId) {
        selectedAttachment = harvesterClientAction.retrieveAttachment(currentHarvester.getId(), currentRun.getId(), logId);
    }
// getter and setter
}
4

1 に答える 1

1

依存関係に Rewrite JSF 統合モジュールが含まれていることを確認してください。

  <dependency>
     <groupId>org.ocpsoft.rewrite</groupId>
     <artifactId>rewrite-integration-faces</artifactId>
     <version>3.4.0.Final</version>
  </dependency>

は、3.4.0.Final 以降、このrewrite-config-prettyfacesモジュールに依存しています。したがって、PrettyFaces 統合をドロップすると、コアの JSF 統合モジュールも失われ、このような問題が発生する可能性があります。

于 2016-08-19T15:55:13.187 に答える