wood burning stoves 2.0*
The moose likes Struts and the fly likes html:checkbox not mapping with form properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:checkbox not mapping with form properties" Watch "html:checkbox not mapping with form properties" New topic
Author

html:checkbox not mapping with form properties

Pravin Sharma
Greenhorn

Joined: Jun 18, 2009
Posts: 11
Hi,
I have used scope as session in struts-config.xml for my action(Struts 1.3).In jsp page i am having some checkboxes which are mapped to forms' some boolean properties.first time when i request that jsp page,i am getting false as all checkbox values .
After checking any checkbox if i submit that form that time i am getting correct values means true.but when i again uncheck that checkboxes,after submiting i am getting old values i.e. true.

Please HELP me.....
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Hi. Can you post the code from your form and from your ActionForm?
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
also tell if your pages are being cached


Experience and talent are independent of age
Pravin Sharma
Greenhorn

Joined: Jun 18, 2009
Posts: 11
No we are avoiding the caching of pages...
here is my code for jsp
<html:form action="AllocationPlanAction">
<table border="0">
<tr id="order" >
<td >
<table border="0">
<tr>
<td class="form">
Start Date
</td>
<td >
<html:text name="allocationPlanForm"
property="planStartDate" styleClass="form" tabindex="-1"
maxlength="25" size="14" readonly="true" />
<input type="image"
src="images\calender_icon.gif" id="imgPlanStartDate"
tabindex="1" width="18" height="16" />

</td>
<td class="form">
Bucket Size
</td>
<td >
<html:text styleClass="form" name="allocationPlanForm"
property="planBucketSize" />
</td>
<td class="form">
<html:checkbox name="allocationPlanForm"
property="allowProjection"/>
Allow Projection
</td>
<td class="form">
<html:checkbox name="allocationPlanForm" property="allMaterialSelected">
All Material
</html:checkbox>
</td>
</tr>
<tr>
<td class="form">
End Date
</td>
<td>
<html:text name="allocationPlanForm" property="planEndDate"
styleClass="form" tabindex="2" maxlength="25" size="14"
readonly="true" />
<input type="image"
src="images\calender_icon.gif" id="imgPlanEndDate"
tabindex="1" width="18" height="16" />

</td>
<td class="form">
<html:checkbox name="allocationPlanForm"
property="inventory" />
Inventory
</td>
<td class="form">
<html:checkbox name="allocationPlanForm" property="freeWIP" />
Free WIP
</td>
<td class="form">
<html:checkbox name="allocationPlanForm" property="freeFG" value="0" />
Free FG
</td>
<td class="form">
<html:checkbox name="allocationPlanForm"
property="allOrderSelected" />
All Order
</td>
</tr>
</table>
</td>
</tr>
</table>
</html:form>



also the form code is:

public class AllocationPlanForm extends ActionForm {
/**
*
*/
private static final long serialVersionUID = 1L;
private String planStartDate;
private String planEndDate;
private String planBucketSize;
private boolean allowProjection;
private boolean inventory;
private boolean freeWIP;
private boolean freeFG;
private boolean allMaterialSelected;
private boolean allOrderSelected;
private String isAllMatSelected;

public String getIsAllMatSelected() {
return isAllMatSelected;
}

public void setIsAllMatSelected(String isAllMatSelected) {
this.isAllMatSelected = isAllMatSelected;
}

public AllocationPlanForm(){
// set the current date to planStartDate by default.
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
java.util.Date date = new java.util.Date();
planStartDate = dateFormat.format(date);
// set the end date to one month after start date by default.
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.DATE, 30);
planEndDate = dateFormat.format(c1.getTime());

planBucketSize = "";
}

public String getPlanStartDate() {
return planStartDate;
}
public void setPlanStartDate(String planStartDate) {
this.planStartDate = planStartDate;
}
public String getPlanEndDate() {
return planEndDate;
}
public void setPlanEndDate(String planEndDate) {
this.planEndDate = planEndDate;
}
public String getPlanBucketSize() {
return planBucketSize;
}
public void setPlanBucketSize(String planBucketSize) {
this.planBucketSize = planBucketSize;
}
public boolean isAllowProjection() {
return allowProjection;
}
public void setAllowProjection(boolean allowProjection) {
this.allowProjection = allowProjection;
}
public boolean isInventory() {
return inventory;
}
public void setInventory(boolean inventory) {
this.inventory = inventory;
}
public boolean isFreeWIP() {
return freeWIP;
}
public void setFreeWIP(boolean freeWIP) {
this.freeWIP = freeWIP;
}
public boolean isFreeFG() {
return freeFG;
}
public void setFreeFG(boolean freeFG) {
this.freeFG = freeFG;
}
public boolean isAllMaterialSelected() {
return allMaterialSelected;
}
public void setAllMaterialSelected(boolean allMaterialSelected) {
this.allMaterialSelected = allMaterialSelected;
}
public boolean isAllOrderSelected() {
return allOrderSelected;
}
public void setAllOrderSelected(boolean allOrderSelected) {
this.allOrderSelected = allOrderSelected;
}


}


i checked one parameter with string property but that time also its not updating.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Please UseCodeTags
Pravin Sharma wrote:I have used scope as session in struts-config.xml for my action(Struts 1.3).In jsp page i am having some checkboxes which are mapped to forms' some boolean properties.first time when i request that jsp page,i am getting false as all checkbox values .
After checking any checkbox if i submit that form that time i am getting correct values means true.but when i again uncheck that checkboxes,after submiting i am getting old values i.e. true.

This problem occurred when you set the form in session scope and not override reset() method, more details here:

ActionForm.html#reset()

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:checkbox not mapping with form properties
 
Similar Threads
html:checkbox
Struts : checkbox status is unchanged if i use back button and uncheck it
checkboxes persistence
Maintain checked and unchecked in checkbox in pagination in display tag in struts
Need suggestions and help for my scenario in struts