> Eg: Evertime I click on a button , A new , not coded text box will
appear. 

How about something like...

(Hint: ProjectBuilder.app -> Project New -> WebObjectsApplication ->
WebScript (no wizard) -> Copy&Paste below -> Save -> Launch -> :-)

- Matt

Main.html
-----
<HTML>
<HEAD>
  <TITLE>WO Example</TITLE>
</HEAD>

<BODY>
    <WEBOBJECT name="FORM">
        <WEBOBJECT name="LIST">
            <WEBOBJECT name="ITEM"></WEBOBJECT><BR>
        </WEBOBJECT>
        <WEBOBJECT name="ADD"></WEBOBJECT>
        <WEBOBJECT name="REMOVE"></WEBOBJECT>
        <HR>
        <WEBOBJECT name="REFRESH"></WEBOBJECT>
    </WEBOBJECT>
    Values = <WEBOBJECT name="VALUES"></WEBOBJECT>
</BODY>
</HTML>


Main.wod
-----
FORM: WOForm {
    multipleSubmit = YES;
}
LIST: WORepetition {
    count = textBoxValues.count;
    index = index;
}
ITEM: WOTextField {
    value = textBoxAtIndex;
}
ADD: WOSubmitButton {
    value = "(+)";
    action = addItem;
}
REMOVE: WOSubmitButton {
    value = "(-)";
    action = removeItem;
}
REFRESH: WOSubmitButton {
    value = "Refresh";
    action = refresh;
}
VALUES: WOString {
    value = textBoxValues;
}


Main.wos
-----
// Main.wo

NSMutableArray *textBoxValues;
id index;

- init
{
    if ([super init]) {
        textBoxValues = [[NSMutableArray alloc] init];
    }
    return self;
}

// Actions
- addItem
{
    [textBoxValues addObject:[[NSString new] autorelease]];
}

- removeItem
{
    if ([textBoxValues count])
        [textBoxValues removeLastObject];
}

- refresh
{
}

// Accessors
- textBoxAtIndex
{
    return [textBoxValues objectAtIndex:index];
}

- setTextBoxAtIndex:value
{
    id safeValue = value;
    if (safeValue == nil)
        safeValue = @"";

    [textBoxValues replaceObjectAtIndex:index withObject:safeValue];
}

Reply via email to