WWW
Michael Kurz | IRIAN
WWW
<h:link outcome="/page.xhtml" value="Page"/>
<a href="/page.jsf">Page</a>
<h:link outcome="/page.xhtml" value="Page">
<f:param name="para" value="1"/>
</h:link>
<a href="/page.jsf?para=1">Page</a>
<h:button outcome="/page.xhtml" value="Page"/>
<input type="button" value="Page"
onclick="window.location.href='/page.jsf'"/>
<f:metadata>
<f:viewParam name="id" value="#{myBean.id}"/>
</f:metadata>
@Named @RequestScoped
public class MyBean {
private long id;
public long getId() {return id;}
public void setId(long id) {this.id = id;}
}
<f:metadata>
<f:viewParam name="id" value="#{bean.id}"/>
<f:viewAction action="#{bean.load}"
onPostback="false"
phase="INVOKE_APPLICATION"/>
</f:metadata>
public String load() {
mail = mailService.findById(id);
return null;
}
<f:event type="preRenderView"
listener="#{bean.preRender}"/>
public void preRender(ComponentSystemEvent event) {
mail = mailService.findById(id);
}
https://github.com/jsflive/jsf-get-examples (jsf-get01)
<h:form>
<h:commandButton action="#{myBean.save}" value="Save"/>
<h:commandButton value="Cancel" immediate="true"
action="myPage?faces-redirect=true&
faces-include-view-params=true"/>
</h:form>
@Named @RequestScoped
public class MyBean {
public String save() {
return "myPage?faces-redirect=true"
+ "&faces-include-view-params=true";
}
}
https://github.com/jsflive/jsf-get-examples (jsf-get02)
http://myshop.at/node.html?mode=list&cat=1234
http://myshop.at/products/books
http://myshop.at/faces/account.xhtml
http://myshop.at/account
@RewriteConfiguration
public class MyConfigurationProvider
extends HttpConfigurationProvider {
@Override
public Configuration getConfiguration(ServletContext c) {
return ConfigurationBuilder.begin()
.addRule(Join.path("/account/")
.to("/faces/account.xhtml"));
}
@Override
public int priority() {return 10;}
}
@Named
@RequestScoped
@Join(path="/account", to="/faces/account.xhtml")
public class AccountPage {}
http://myshop.at/faces/products/details.xhtml?id=123
http://myshop.at/product/123
@RewriteConfiguration
public class MyConfigurationProvider
extends HttpConfigurationProvider {
@Override
public Configuration getConfiguration(ServletContext c) {
return ConfigurationBuilder.begin()
.addRule(Join.path("/product/{id}")
.to("/faces/products/details.xhtml"));
}
@Override
public int priority() {return 10;}
}
@Named
@RequestScoped
@Join(path = "/product/{id}",
to="/faces/products/details.xhtml")
public class ProductDetailsPage {}
https://github.com/jsflive/jsf-get-examples (jsf-get03)