Hi all...
I have added 3 radio buttons on my
JSF from. I want to store value of selected radio button into bean so that I can display it on the JSF from. Can anybody please suggest how to get it??
Also with calender, When i display the selected date on the JSF from it shows previous day, not the selected day. But when i display in console it shows the selected day without problem..
Following is code I used in the JSF.
<h:form id="calendarForm">
<style type="text/css">
.yearRowStyle {
background-color: #A8D1E8;
color: red;
text-align: center;
font-weight: bold;
font-style:italic;
}
.weekRowStyle {
background-color: #D6EBFC;
}
.selectedDayCellStyle {
background-color: #ECD5D2;
}
</style>
<h3> <h:outputText value="Select Date" style="color:blue"/> </h3>
<t:inputCalendar id="MyCalendar" monthYearRowClass="yearRowStyle"
weekRowClass="weekRowStyle"
currentDayCellClass="selectedDayCellStyle"
value="#{calendarBean.selectedDate}" />
<br><br>
<t:selectOneRadio id="SR" value="SI"
layout="spread"
border="1"
style="font-weight:bold" binding="#{calendarBean.radioSelect}" >
<f:selectItem id="sel1" itemLabel="Public Holiday" itemValue="ph" />
<f:selectItem id="sel2" itemLabel="General Holiday" itemValue="gh" />
<f:selectItem id="sel3" itemLabel="Festival Holiday" itemValue="fh" />
</t:selectOneRadio>
<h3> <h:outputText value="Select Holiday Type" style="color:blue"/> </h3>
<t:panelGrid columns="1" width="20%" style="color:red;"
cellpadding="0" cellspacing="5">
<t:panelGroup>
<t:radio for="SR" index="0"></t:radio>
</t:panelGroup>
<t:panelGroup>
<t:radio for="SR" index="1"></t:radio>
</t:panelGroup>
<t:panelGroup>
<t:radio for="SR" index="2"></t:radio>
</t:panelGroup>
</t:panelGrid>
<br><br>
<h:commandButton id="dateBtn" value="Submit" action="#{calendarBean.onDate}" />
</h:form>
AND my bean java file is..
package com.calendar.web;
import java.util.Date;
public class Calendar
{
Date selectedDate;
String radioSelect;
public Date getSelectedDate() {
return selectedDate;
}
public void setSelectedDate(Date selectedDate) {
this.selectedDate = selectedDate;
}
public String getRadioSelect() {
return radioSelect;
}
public void setRadioSelect(String radioSelect) {
this.radioSelect = radioSelect;
}
public String onDate()
{
String a=selectedDate.toString();
System.out.println(a);
System.out.println(radioSelect);
return "dateSelect";
}
}