Java Reference
In-Depth Information
Click here to view code image
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<h:outputStylesheet library="css" name="default.css"/>
<title>String Encoder</title>
</h:head>
<h:body>
<h2>String Encoder</h2>
<p>Type a string and an integer, then click Encode.</p>
<p>Depending on which alternative is enabled, the coder bean
will either display the argument values or return a
string that
shifts the letters in the original string by the value
you specify.
The value must be between 0 and 26.</p>
<h:form id="encodeit">
<p><h:outputLabel value="Type a string: "
for="inputString"/>
<h:inputText id="inputString"
value="#{coderBean.inputString}"/>
<h:outputLabel value="Type the number of letters to
shift by: "
for="transVal"/>
<h:inputText id="transVal"
value="#{coderBean.transVal}"/></p>
<p><h:commandButton value="Encode"
ac-
tion="#{coderBean.encodeString()}"/></p>
<p><h:outputLabel value="Result: " for="outputString"/>
<h:outputText id="outputString"
value="#{coderBean.codedString}"
style="color:blue"/> </p>
<p><h:commandButton value="Reset" ac-
tion="#{coderBean.reset}"/></p>
</h:form>
...
</h:body>
</html>
When the user clicks the Encode button, the page invokes the managed bean's en-
codeString method and displays the result, coderBean.codedString , in blue.
The page also has a Reset button that clears the fields.
Search WWH ::




Custom Search