| 1 33 package com.icesoft.applications.faces.address; 34 35 import java.io.IOException ; 36 import java.io.InputStreamReader ; 37 import java.io.Reader ; 38 import java.io.StringWriter ; 39 40 44 public class ReadmeBean { 45 46 private boolean expanded = false; 47 48 private String readmeText = "Readme"; 49 private static String README = "View Demo Notes"; 50 private static String CLOSEME = "Close Demo Notes"; 51 52 private String buttonLabel = README; 54 private static final String VIEWIMG = "./images/view-notes-button.gif"; 55 private static final String HIDEIMG = "./images/hide-notes-button.gif"; 56 private String imageButton = VIEWIMG; 57 58 public ReadmeBean() { 60 try { 61 Reader readmeReader = new InputStreamReader ( 62 this.getClass() 63 .getClassLoader() 64 .getResourceAsStream( 65 "com/icesoft/applications/faces/address/readme.html")); 66 StringWriter readmeWriter = new StringWriter (); 67 68 char[] buf = new char[2000]; 69 int len; 70 try { 71 while ((len = readmeReader.read(buf)) > -1) { 72 readmeWriter.write(buf, 0, len); 73 } 74 } catch (IOException e) { 75 e.printStackTrace(); 76 } 77 78 this.readmeText = readmeWriter.toString(); 79 } catch (Exception e) { 80 e.printStackTrace(); 81 } 82 } 83 84 public ReadmeBean(String readmeText) { 85 this.readmeText = readmeText; 86 } 87 88 public String getReadmeText() { 89 return readmeText; 90 } 91 92 public String getButtonLabel() { 93 return buttonLabel; 94 } 95 96 public String getImageButton() { 97 return imageButton; 98 } 99 100 public String pressExpandButton() { 101 expanded = !expanded; 102 if (expanded) { 103 this.imageButton = HIDEIMG; 104 this.buttonLabel = CLOSEME; 105 } else { 106 this.imageButton = VIEWIMG; 107 this.buttonLabel = README; 108 } 109 return "success"; 110 } 111 112 public boolean isExpanded() { 113 return expanded; 114 } 115 116 public void setExpanded(boolean expanded) { 117 this.expanded = expanded; 118 } 119 } | Popular Tags |