私は現在、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で動作しない理由を知っていますか?commandLinkが書き換えRewriteRuleでアクションを呼び出せません
私のクラスパスは、次の書き換えのjarファイルが含ま:
- 書き換え-サーブレット3.4.0.Final.jar
- 書き換え-CONFIG-prettyfaces-3.4.0.Final.jarを(これがドロップされました
以下に、私のコードの断片を見つけることができます。
ありがとうございます!
:
マイプリティ-config設定この設定
<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アクション
@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
}
クラスパスにあるJARファイルを書き換えることはできますか? – chkal
@chkal投稿を更新しました。これはrewrite-servlet-3.4.0.Final.jarだけです – cpoeth