-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add demo for multiple container updates
- Loading branch information
1 parent
1dc850a
commit ba2e1f7
Showing
8 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Examples/Ajax/AjaxExample/Components/MultiUpdateExample.wo/MultiUpdateExample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<webobject name = "AjaxExampleComponent"> | ||
<p> | ||
This example demonstrates the AjaxTrigger component, which allows you to enqueue a series of updates to | ||
occur. Note that these happen in series as multiple requests, not as a single request, so you will want | ||
to limit the number of updates you do in a single pass. | ||
</p> | ||
|
||
<webobject name = "AjaxUpdateContainer"> | ||
<h1>Container 1</h1> | ||
<webobject name = "Now"/> | ||
|
||
<webobject name = "WOForm"> | ||
<webobject name = "AjaxSubmitButton"></webobject>, and also update: | ||
<p> | ||
<webobject name = "WOCheckBox"></webobject> Container 2 | ||
</p> | ||
<p> | ||
<webobject name = "WOCheckBox1"></webobject> Container 3 | ||
</p> | ||
</webobject> | ||
</webobject> | ||
|
||
<webobject name = "AjaxUpdateContainer1"> | ||
<h1>Container 2</h1> | ||
<webobject name = "Now1"/> | ||
</webobject> | ||
|
||
<webobject name = "AjaxUpdateContainer2"> | ||
<h1>Container 3</h1> | ||
<webobject name = "Now2"/> | ||
</webobject> | ||
</webobject> |
47 changes: 47 additions & 0 deletions
47
Examples/Ajax/AjaxExample/Components/MultiUpdateExample.wo/MultiUpdateExample.wod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
AjaxExampleComponent : AjaxExampleComponent { | ||
title = "Update Trigger"; | ||
} | ||
|
||
AjaxUpdateContainer : AjaxUpdateContainer { | ||
id = "container1"; | ||
style = "background: green; color: white; padding: 10px"; | ||
} | ||
|
||
Now : WOString { | ||
value = now; | ||
} | ||
|
||
WOForm : WOForm { | ||
multipleSubmit = true; | ||
} | ||
|
||
AjaxSubmitButton : AjaxSubmitButton { | ||
updateContainerID = containerIdsToUpdate; | ||
value = "Update Container 1"; | ||
} | ||
|
||
WOCheckBox : WOCheckBox { | ||
checked = updateContainer2; | ||
} | ||
|
||
WOCheckBox1 : WOCheckBox { | ||
checked = updateContainer3; | ||
} | ||
|
||
AjaxUpdateContainer1 : AjaxUpdateContainer { | ||
id = "container2"; | ||
style = "background: blue; color: white; padding: 10px"; | ||
} | ||
|
||
Now1 : WOString { | ||
value = now; | ||
} | ||
|
||
AjaxUpdateContainer2 : AjaxUpdateContainer { | ||
id = "container3"; | ||
style = "background: red; color: white; padding: 10px"; | ||
} | ||
|
||
Now2 : WOString { | ||
value = now; | ||
} |
4 changes: 4 additions & 0 deletions
4
Examples/Ajax/AjaxExample/Components/MultiUpdateExample.wo/MultiUpdateExample.woo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"WebObjects Release" = "WebObjects 5.0"; | ||
encoding = "UTF-8"; | ||
} |
6 changes: 3 additions & 3 deletions
6
Examples/Ajax/AjaxExample/Components/UpdateTriggerExample.wo/UpdateTriggerExample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import com.webobjects.appserver.WOComponent; | ||
import com.webobjects.appserver.WOContext; | ||
import com.webobjects.foundation.NSArray; | ||
import com.webobjects.foundation.NSMutableArray; | ||
|
||
public class MultiUpdateExample extends WOComponent { | ||
|
||
private NSMutableArray<String> _updateContainerIDs = new NSMutableArray<>("container1"); | ||
private long now; | ||
|
||
public MultiUpdateExample(WOContext context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public void awake() { | ||
now = System.currentTimeMillis(); | ||
|
||
super.awake(); | ||
} | ||
|
||
public long now() { | ||
return now; | ||
} | ||
|
||
public NSArray containerIdsToUpdate() { | ||
return _updateContainerIDs; | ||
} | ||
|
||
public void setUpdateContainer2(boolean updateContainer2) { | ||
setUpdateContainer("container2", updateContainer2); | ||
} | ||
|
||
public boolean updateContainer2() { | ||
return _updateContainerIDs.containsObject("container2"); | ||
} | ||
|
||
public void setUpdateContainer3(boolean updateContainer3) { | ||
setUpdateContainer("container3", updateContainer3); | ||
} | ||
|
||
public boolean updateContainer3() { | ||
return _updateContainerIDs.containsObject("container3"); | ||
} | ||
|
||
protected void setUpdateContainer(String id, boolean updateContainer3) { | ||
if (updateContainer3) { | ||
if (!_updateContainerIDs.containsObject(id)) { | ||
_updateContainerIDs.addObject(id); | ||
} | ||
} | ||
else { | ||
_updateContainerIDs.removeObject(id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters