public
Created

  • Download Gist
Controller.java
Java
1 2 3
if (len <= 0) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You must enter a temperature"));
}
index.xhtml
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<div id="container">
<h:form id="convertForm">
<h:panelGrid columns="4">
<h:outputLabel for="tempFrom">Temperature:</h:outputLabel>
<h:inputText value="#{tempFrom}" id="tempFrom" />
<h:message for="tempFrom" errorClass="invalid" />
<h:commandButton id="add" value="Convert"
action="#{tempConvert.setTempFrom(tempFrom)}">
</h:commandButton>
</h:panelGrid>
</h:form>
<h:form id="response">
<h:panelGrid columns="2">
<h:outputLabel>Converts to:</h:outputLabel>
<h:outputLabel value="#{tempConvert.temperature}" />
</h:panelGrid>
</h:form>
</div>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.