I need reload the content of a div with a part of an object JSON.
The code below does it perfectly, but the resulting div get all the JSON object and between {}
. I need the content to appear only one variable.
JSP:
<s:url id="ajax1" value="ajax1.action"/>
<sj:div id="div1"
href="%{ajax1}"
reloadTopics="reloaddiv1">
</sj:div>
<sj:a
id="refreshlink"
onClickTopics="refreshdiv"
button="true">Refresh Div
</sj:a>
JavaScript:
<script type="text/javascript">
$.subscribe('refreshdiv', function(event,data) {
$.publish('reloaddiv1');
});
</script>
My action:
<package name="default" extends="struts-default,json-default" namespace="/">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult" />
</result-types>
<action name="ajax1" class="action.Div">
<result type="json"/>
</action>
</package>
MY CLASS action.Div
String hi = "hi world";
String bye = "bye world";
@Override
public String execute() throws Exception {
return SUCCESS;
}
/* getters and setters*/
Output shown in my div:
{"bye":"bye world","hi":"hi world"}
How do I make you see just "hi world"
?