Re: WORepitition not saving (Sorry for messy last message)
Re: WORepitition not saving (Sorry for messy last message)
- Subject: Re: WORepitition not saving (Sorry for messy last message)
- From: Ken Anderson <email@hidden>
- Date: Mon, 12 Jun 2006 12:32:02 -0400
Don,
Why do you have 2 methods for each? I see setIsCustodian and
setCustodian... Also, in setIsCustodian, you're sending a string to
takeStoredValueForKey:
takeStoredValueForKey((bValue?"1":"0"), "custodian");
where custodian should be a number, as shown in the setCustodian method:
takeStoredValueForKey(value, "custodian");
Maybe you could rewrite it like this:
takeStoredValueForKey((bValue?new Integer(1):new Integer
(0)), "custodian");
I would say this is the most likely problem. Why are you doing it
this way?
Ken
On Jun 12, 2006, at 11:59 AM, Don wrote:
Hello All;
Sorry, my last message came through as html markup. I made this
one plain text. Sorry for filling up your email boxes. I am using
WO 5.3 on Tiger with an Oracle 10G 10.0.3.0 database. I am able to
render a listing of people with two checkboxes (the fields in the
database are numeric for these checkboxes) The fields are named
trainer and custodian.
Everything renders correctly, puling the correct data etc. However
if I check any of the boxes then press my save button (which is a
submit) (WORepetition and Submit are inside a form). It does not
appear any changes are being saved.
I have included the source from page as well as the java source, eo
model class, and table structure.
Please help, I am sure it is something small that is causing the
error. Thanks, Don
Java source:
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
import com.webobjects.security.*;
import com.webobjects.examples.utilities.*;
import com.webobjects.appserver.WOContext;
public class agents extends AbstractSubComponent {
/** @TypeInfo Agent */
public NSMutableArray AgentList;
public Agent anAgent;
public agents(WOContext context) {
super(context);
}
public void appendToResponse(WOResponse response, WOContext context) {
EOFetchSpecification fetchSpec = null;
EOEditingContext ec = null;
try{
ec = session().defaultEditingContext();
fetchSpec = new EOFetchSpecification("Agent",null,null);
//EOFetchSpecification.fetchSpecificationNamed("byName","Agent");
NSArray tempT = ec.objectsWithFetchSpecification(fetchSpec);
AgentList = new NSMutableArray(tempT);
WXDebug.println(7, "AgentList:"+AgentList.count());
} catch(Exception e){
WXDebug.println(1, "e:"+e);
e.printStackTrace();
} finally{
super.appendToResponse(response,context);
}
}
public WOComponent saveAgent()
{
EOEditingContext ec = null;
try{
ec = session().defaultEditingContext();
//WXDebug.println(1,);
ec.saveChanges();
WXDebug.println(1, "Agents.java:saveAgent()");
} catch( Exception e) {
WXDebug.println(1, "An Error Occurred in Agents.java:SaveAgent()
error:"+e);
e.printStackTrace();
} finally {
//ec.unlock();
}
return null;
}
}
Page source:
<webobject name="pgAgents"><webobject name="Form1"><webobject
name="tableList"><table cellspacing="0" border="0"
cellpadding="0"><THEAD><tr><td align="right" style="text-
align:right;" colspan="6"><b># of Agents: <webobject
name="String2"></webobject> <webobject
name="SubmitButton1"></webobject></b></td></tr></
THEAD><TFOOT><tr><th width="200">Agent Name</th><th
width="50">Trainer</th><th width="70">Custodian</th><th
width="150">Assigned Weapons</th><th width="100">Offices</th></tr></
TFOOT></table><div id="Yikes"><table cellspacing="0"
cellpadding="0" border="0"><webobject name="Repetition1"><tr><td
align="left" width="200" valign="bottom"> <webobject
name="String1"></webobject></td><td align="center"
width="50"><webobject name="CheckBox1"></webobject></td><td
align="center" width="70"><webobject name="CheckBox2"></webobject></
td><td width="150"></td><td width="100"></td></tr></webobject></
table></div></webobject></webobject></webobject>
Page parameters:
CheckBox1: WOCheckBox {
checked = anAgent.isTrainer;
}
CheckBox2: WOCheckBox {
checked = anAgent.isCustodian;
}
Form1: WOForm {
multipleSubmit = false;
}
Repetition1: WORepetition {
item = anAgent;
list = AgentList;
}
String1: WOString {
value = anAgent.agent_person.fullNameReverse;
}
String2: WOString {
value = AgentList.@count;
}
SubmitButton1: WOSubmitButton {
action = saveAgent;
value = "Save";
class = "systemButton";
disabled = false;
}
pgAgents: PageWrapper {
title = "here";
}
tableList: tableoutline {
tableHeight = "500";
}
Agents EO class:
// Agent.java
// Created on Thu Jun 01 09:28:38 US/Eastern 2006 by Apple
EOModeler Version 5.2
import com.webobjects.foundation.*;
import com.webobjects.eocontrol.*;
import com.webobjects.examples.utilities.*;
import java.math.BigDecimal;
import java.util.*;
public class Agent extends EOGenericRecord {
public Agent() {
super();
}
/*
// If you implement the following constructor EOF will use it to
// create your objects, otherwise it will use the default
// constructor. For maximum performance, you should only
// implement this constructor if you depend on the arguments.
public Agent(EOEditingContext context, EOClassDescription
classDesc, EOGlobalID gid) {
super(context, classDesc, gid);
}
// If you add instance variables to store property values you
// should add empty implementions of the Serialization methods
// to avoid unnecessary overhead (the properties will be
// serialized for you in the superclass).
private void writeObject(java.io.ObjectOutputStream out) throws
java.io.IOException {
}
private void readObject(java.io.ObjectInputStream in) throws
java.io.IOException, java.lang.ClassNotFoundException {
}
*/
public Number person_identifier() {
return (Number)storedValueForKey("person_identifier");
}
public void setPerson_identifier(Number value) {
takeStoredValueForKey(value, "person_identifier");
}
public Number Trainer() {
return (Number)storedValueForKey("trainer");
}
public void setTrainer(Number value) {
takeStoredValueForKey(value, "trainer");
}
public Number Custodian() {
return (Number)storedValueForKey("custodian");
}
public void setCustodian(Number value) {
takeStoredValueForKey(value, "custodian");
}
public boolean isCustodian() {
try {
return (((Number)storedValueForKey("custodian")).intValue()==1);
} catch (Exception e) {
return false;
}
}
public void setIsCustodian(boolean bValue) {
WXDebug.println(1, "Custodian Set :"+(bValue?"1":"0"));
takeStoredValueForKey((bValue?"1":"0"), "custodian");
}
public boolean isTrainer() {
try {
return (((Number)storedValueForKey("trainer")).intValue()==1);
} catch (Exception e) {
return false;
}
}
public void setIsTrainer(boolean bValue) {
WXDebug.println(1, "Trainer Set :"+(bValue?"1":"0"));
takeStoredValueForKey((bValue?"1":"0"), "trainer");
}
public Person agent_person() {
return (Person)storedValueForKey("agent_person");
}
public void setAgent_person(Person value) {
takeStoredValueForKey(value, "agent_person");
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden