Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml"
  5. xmlns:f="http://java.sun.com/jsf/core"
  6. xmlns:h="http://java.sun.com/jsf/html">
  7. <h:head>
  8. <title>Inject test</title>
  9. </h:head>
  10. <h:body>
  11. <h:messages/>
  12. <h:form>
  13. <p>Enter a path:</p>
  14. <h:inputText id="path" value="#{injecttest.thePath}"/>
  15. <h:commandButton id="save" value="Save" action="#{injecttest.saveForm}"/>
  16. </h:form>
  17. </h:body>
  18. </html>
  19.  
  20. import javax.faces.bean.ManagedProperty;
  21.  
  22. @javax.faces.bean.ManagedBean(name = "injecttest")
  23. @javax.faces.bean.ViewScoped
  24. @com.ocpsoft.pretty.faces.annotation.URLMappings(mappings = {
  25. @com.ocpsoft.pretty.faces.annotation.URLMapping(
  26. id = "injecttest-add",
  27. pattern = "/injecttest/",
  28. viewId = "/pages/injecttest.xhtml"
  29. ),
  30. @com.ocpsoft.pretty.faces.annotation.URLMapping(
  31. id = "injecttest-edit",
  32. pattern = "/injecttest/#{/.+/ path.path}",
  33. viewId = "/pages/injecttest.xhtml"
  34. )
  35. })
  36. public class InjectTest {
  37. @ManagedProperty(name = "path", value = "#{path}")
  38. private Path thePath;
  39. private String path;
  40.  
  41. public void setPath(Path p) {
  42. thePath = p;
  43. path = p.getPath();
  44. }
  45.  
  46. public void setThePath(String p) {
  47. path = p;
  48. }
  49.  
  50. public String getThePath() {
  51. return path;
  52. }
  53.  
  54. public String saveForm() {
  55. thePath.setPath(path);
  56. return "pretty:injecttest-edit";
  57. }
  58. }
  59.  
  60. @javax.faces.bean.ManagedBean(name = "path")
  61. @javax.faces.bean.ViewScoped
  62. public class Path {
  63. private String path;
  64.  
  65. public void setPath(String thePath) {
  66. path = thePath;
  67. }
  68.  
  69. public String getPath() {
  70. return path;
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement