Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
HTML
HTML
1JSP page
<s:url id="optionsUrl" namespace="/autocompleter" action="getStates" />

<sx:autocompleter href="%{#optionsUrl}" />
Example action

When a form containing an autocompleter is submitted, two values will be submitted for each autocompleter, one for the selected value, and one for its associated key.

The action:

Code Block
java
java
titleMyAction.java

public MyAction extends ActionSupport {
    private String optionsKey;
    private String options;

    ...    
}

The JSP:

Code Block
HTML
HTML

<s:form id="form">
  <sx:autocompleter name="options" label="Options" />
</s:form>
Change default key name

The action:

Code Block
java
java
titleMyAction.java

public MyAction extends ActionSupport {
    private String superKey;
    private String options;

    ...    
}

The JSP:

Code Block
HTML
HTML

<s:form id="form">
  <sx:autocompleter keyName="superKey" name="options" label="Options" />
</s:form>
JSON accepted

for this autocompleter:

Code Block
HTML
HTML

<s:form id="form">
  <sx:autocompleter name="state" />
</s:form>

The following JSON will be accepted:

Code Block
javascript
javascript
titleMap(recommended as it is the easiest one to generate)

{
    "Alabama" : "AL",
    "Alaska"  : "AK"
}
Code Block
javascript
javascript
titleArray of arrays

[
    ["Alabama", "AL"],
    ["Florida", "FL"]
]
Code Block
javascript
javascript
titleArray inside object, same name as field

{
    "state" : [
        ["Alabama","AL"],
        ["Alaska","AK"]
    ]
}     
Code Block
javascript
javascript
titleMap inside object, same name as field

{
    "state" : {
        "Alabama" : "AL",
        "Alaska"  : "AK"
    }
}     
Code Block
javascript
javascript
titleArray inside object, field in response starts with the name of the autocompleter("state" in this example)

{
    "states" : {
        "Alabama" : "AL",
        "Alaska"  : "AK"
    }
}     
Code Block
javascript
javascript
titleNo name match, use first array found, and hope for the best

{
    "Australopithecus" : [
       ["Alabama","AL"],
       ["Alaska","AK"]
    ]
}     
Load characters while user types (when text size >= 3)

...