I'm having a problem with Java Server Faces... Actually, I don't know what to do.
The exercise is to make a BMI (Body Mass Index) app with Java Server Faces. You put your name, your birthdate (i.e: 10/03/2000, 19 years ago. BTW I use dd/MM/yyyy), weight (kg) and height (cm).
Click to calculate your BMI and in the other page it shows your name, your age (that'd be 19 with the example) and your BMI. The problem that I'm having is that I don't know how to show in the page the age, only the date that I put in the first place (Day of the week in that year, March, 2000).
Can someone help me, please ? I'm still learning. Do I need to create a converter Age class ? Some function might help me ?
P.S: The variables are in portuguese, so: Nome = Name, Data de Nascimento = BirthDate, Peso = Weight, Altura = Height, Idade = Age, IMC = BMI, Dados = Data, dadosIMC = BMIData
Thanks for reading, the xhtml code is below.
<h:body> <!--INDEX-->
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="Nome:" for="nome"/>
<h:inputText value="#{dadosIMC.dados.nome}" id="nome"
label="nome"/>
<h:outputLabel value="Data de Nascimento:" for="nascimento"/>
<h:inputText value="#{dadosIMC.dados.nascimento}" id="nascimento"
label="data de nascimento"
validatorMessage="#{msgs.erroNascimento}">
<f:convertDateTime type="date" pattern="dd/MM/yyyy" />
</h:inputText>
<h:outputLabel value="Peso (KG):" for="peso"/>
<h:inputText value="#{dadosIMC.dados.peso}" id="peso"
label="peso"/>
<h:outputLabel value="Altura (CM):" for="altura"/>
<h:inputText value="#{dadosIMC.dados.altura}" id="altura"
label="altura"/>
</h:panelGrid>
<h:commandButton value="Calcular" action="#{dadosIMC.dados.calculaIMC()}"/>
</h:form>
</h:body>
<h:body> <!--RESULT PAGE-->
<h:panelGrid columns="2">
Nome:
<h:outputText value="#{dadosIMC.dados.nome}"/>
Idade:
<h:outputText value="don't know what to put"/>
IMC:
<h:outputText value="#{dadosIMC.dados.resultado}"/>
</h:panelGrid>
<h:button value="Voltar" outcome="/index"/>
</h:body>