Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <!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:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html">
- <h:head>
- <title>Inject test</title>
- </h:head>
- <h:body>
- <h:messages/>
- <h:form>
- <p>Enter a path:</p>
- <h:inputText id="path" value="#{injecttest.thePath}"/>
- <h:commandButton id="save" value="Save" action="#{injecttest.saveForm}"/>
- </h:form>
- </h:body>
- </html>
- import javax.faces.bean.ManagedProperty;
- @javax.faces.bean.ManagedBean(name = "injecttest")
- @javax.faces.bean.ViewScoped
- @com.ocpsoft.pretty.faces.annotation.URLMappings(mappings = {
- @com.ocpsoft.pretty.faces.annotation.URLMapping(
- id = "injecttest-add",
- pattern = "/injecttest/",
- viewId = "/pages/injecttest.xhtml"
- ),
- @com.ocpsoft.pretty.faces.annotation.URLMapping(
- id = "injecttest-edit",
- pattern = "/injecttest/#{/.+/ path.path}",
- viewId = "/pages/injecttest.xhtml"
- )
- })
- public class InjectTest {
- @ManagedProperty(name = "path", value = "#{path}")
- private Path thePath;
- private String path;
- public void setPath(Path p) {
- thePath = p;
- path = p.getPath();
- }
- public void setThePath(String p) {
- path = p;
- }
- public String getThePath() {
- return path;
- }
- public String saveForm() {
- thePath.setPath(path);
- return "pretty:injecttest-edit";
- }
- }
- @javax.faces.bean.ManagedBean(name = "path")
- @javax.faces.bean.ViewScoped
- public class Path {
- private String path;
- public void setPath(String thePath) {
- path = thePath;
- }
- public String getPath() {
- return path;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement