Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-Alpha2
-
Component/s: ICE-Components
-
Labels:None
-
Environment:ICEfaces 2.0, Sparkle component platform
-
Affects:Documentation (User Guide, Ref. Guide, etc.)
Description
Should have a utility API that builds the parameter strings, performs param escaping.
- Yip suggests that the JSON "stringify" function would suffice, if we can implement one.
- param builder API should not send parameters that have the default value
- param builder API should not send parameters for disabled features
- API should perform escaping for security and correctness
- Yip suggests that the JSON "stringify" function would suffice, if we can implement one.
- param builder API should not send parameters that have the default value
- param builder API should not send parameters for disabled features
- API should perform escaping for security and correctness
Activity
Ken Fyten
created issue -
Ken Fyten
made changes -
Field | Original Value | New Value |
---|---|---|
Salesforce Case | [] | |
Fix Version/s | 2.0-Beta [ 10231 ] | |
Affects | [Documentation (User Guide, Ref. Guide, etc.)] | |
Assignee Priority | P2 | |
Assignee | Yip Ng [ yip.ng ] |
Mark Collette
made changes -
Salesforce Case | [] | |
Security | Private [ 10001 ] |
Mark Collette
made changes -
Link | This issue blocks ICE-5847 [ ICE-5847 ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #21852 | Tue Jul 06 16:12:23 MDT 2010 | yip.ng | |
Files Changed | ||||
ADD
/icefaces/scratchpads/sparkle/component/src/org/icefaces/component/utils/JSONBuilder.java
MODIFY /icefaces/scratchpads/sparkle/component/src/org/icefaces/component/selectinputdate/SelectInputDateRenderer.java |
yip.ng
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #21859 | Wed Jul 07 15:32:18 MDT 2010 | yip.ng | |
Files Changed | ||||
MODIFY
/icefaces/scratchpads/sparkle/component/src/org/icefaces/component/utils/JSONBuilder.java
|
Ken Fyten
made changes -
Resolution | Fixed [ 1 ] | |
Status | Resolved [ 5 ] | Reopened [ 4 ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #21866 | Thu Jul 08 09:50:05 MDT 2010 | yip.ng | |
Files Changed | ||||
MODIFY
/icefaces/scratchpads/sparkle/component/src/org/icefaces/component/utils/JSONBuilder.java
|
yip.ng
made changes -
Attachment | screenshot-01.png [ 12427 ] | |
Attachment | screenshot-02.png [ 12428 ] |
yip.ng
made changes -
Status | Reopened [ 4 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #21876 | Thu Jul 08 15:56:34 MDT 2010 | judy.guglielmin | update for |
Files Changed | ||||
MODIFY
/icefaces/scratchpads/sparkle/component/src/org/icefaces/component/menubutton/MenuButtonRenderer.java
|
Ken Fyten
made changes -
Fix Version/s | 2.0-Beta2 [ 10242 ] | |
Fix Version/s | 2.0-Beta1 [ 10231 ] |
Ken Fyten
made changes -
Security | Private [ 10001 ] |
Ken Fyten
made changes -
Fix Version/s | 2.0.0 [ 10230 ] |
Ken Fyten
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Assignee Priority | P2 |
http://www.json.org/
After discussing the pros and cons of (A) creating a Map of parameters and serialising that to a JSON string; and (B) programmatically calling methods on a ResponseWriter-esque helper object to generate the JSON string; we've chosen (B). Here is the suggestion for how to implement that idea.
Say we want to output a string that creates a javascript map, with a nested map, as well as String, integer and boolean values:
{a:
{b:true,c:'hi'},d:25}
Re-written with more white-space, for greater clarity:
{
{ b:true, c:'hi' }a:
,
d:25
}
We could make use of a utility object, that provides an API similar to StringBuilder, but javascript variable oriented, instead of char oriented:
JSONBuilder builder = new JSONBuilder();
builder.beginMap().
beginMap("a").
entry("b", true).
entry("c", "hi").
endMap().
entry("d", 25).
endMap();
String json = builder.toString();
Or, slightly more succinctly:
String json = JSONBuilder.create().
beginMap().
beginMap("a").
entry("b", true).
entry("c", "hi").
endMap().
entry("d", 25).
endMap().toString();
All the methods in JSONBuilder return the reference to itself, to simplify further operations on it. JSONBuilder.create() just makes a new instance. Every JSONBuilder internally uses a StringBuilder, whose toString() is returned by JSONBuilder.toString().
beginMap() just appends: "{"
{" endMap() appends: "}beginMap(String key) appends: key + "
"
There would be versions of entry(String key, X value) that take: int, long, float, double, boolean, String. They basically append: key + ":" + value. The String one adds quotes and does JSON string escaping, like how the link above describes.
beginMap(String key) and entry(String key, X value) need to use some internal state for managing when to append a comma.