Apologies for the delay - Thanksgiving got in the way....
My action is below. Struts and Json plugin version is 2.3.16.3.
The SearchCriteria.java object is a standard bean object with getters and
setters (no real functionality). My action class is below which is
processing the url query: "ContactSearchJson.action?searchCriteria.
searchStringContact=Doe&searchCriteria.categories=agent". I also included
my struts.xml applicable lines.
=========== ContactSerachJsonAction.java =========================
package com.afs.web.action.json;
public class ContactSearchJsonAction extends BaseAction {
private static final int DEFAULT_PAGESIZE = 20;
private transient SearchManagerService searchManagerService;
private SearchCriteria searchCriteria;
private Map<Integer, String> contactData;
private Integer count;
public String execute() throws Exception {
searchCriteria.setUserId(myAppSession.getUser().getAppUserId());
searchCriteria.setTeamId(myAppSession.getUser().getTeam().getTeamId());
searchManagerService.setSearchCriteria(searchCriteria);
searchManagerService.setTemplate(SearchManagerService.TEMPLATE_CUSTOM);
List<Contact> contacts =
searchManagerService.performPagedSearch(Contact.class, 0,
DEFAULT_PAGESIZE);
contactData = new HashMap<Integer, String>();
for (Contact contact : contacts) {
String displayName = "";
if (StringUtils.isNotBlank(contact.getCompany())) {
displayName = "(" + displayName + contact.getCompany() + ") ";
}
displayName = displayName +
contact.getContactHelper().getName().getFirstLastAllString(true);
contactData.put(contact.getContactId(), displayName);
}
count = searchManagerService.getPage().getTotalNumberOfElements();
return SUCCESS;
}
public void setSearchManagerService(SearchManagerService
searchManagerService) {
this.searchManagerService = searchManagerService;
}
public void setSearchCriteria(SearchCriteria searchCriteria) {
this.searchCriteria = searchCriteria;
}
public Map<Integer, String> getContactData() {
return contactData;
}
public Integer getCount() {
return count;
}
}
========= struts.xml ============
<package name="jsonSecure" namespace="/app/json" extends="json-default">
<!-- Define results: custom json result (dynamically changes
result type) -->
<result-types>
<result-type name="myJsonResult"
class="com.afs.web.interceptor.JsonDynamicContentTypeResult"/>
</result-types>
<!-- Define custom interceptors and interceptor stacks -->
<interceptors>
<!-- Session Interceptor: makes sure user is logged in -->
<interceptor name="sessionInterceptorJson"
class="com.afs.web.interceptor.SessionInterceptorJson" />
<!-- Replace the existing "exception" interceptor -->
<interceptor name="exceptionInterceptor"
class="com.afs.web.interceptor.ExceptionInterceptorJson" />
<!-- Default stack -->
<interceptor-stack name="myDefaultStackJson">
<interceptor-ref name="sessionInterceptorJson" />
<interceptor-ref name="exceptionInterceptor">
<param name="logEnabled">true</param>
<param name="logLevel">ERROR</param>
</interceptor-ref>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param
name="excludeParams">^class\..*,^dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,^parameters\..*,^action:.*,^method:.*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="deprecation"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
<interceptor-ref name="jsonValidation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
<!-- Preparable default stack -->
<interceptor-stack name="myPreparableStackJson">
<interceptor-ref name="sessionInterceptorJson" />
<interceptor-ref name="exceptionInterceptor">
<param name="logEnabled">true</param>
<param name="logLevel">ERROR</param>
</interceptor-ref>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param
name="excludeParams">^class\..*,^dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,^parameters\..*,^action:.*,^method:.*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="deprecation"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
<interceptor-ref name="jsonValidation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
</interceptors>
<!-- Set default interceptor -->
<default-interceptor-ref name="myDefaultStackJson" />
<!-- define global results to include action messages -->
<global-results>
<result name="login" type="myJsonResult">
<param name="ignoreHierarchy">false</param>
<param
name="includeProperties">actionErrors.*,actionMessages.*,fieldErrors.*</param>
</result>
<result name="input" type="myJsonResult">
<param name="ignoreHierarchy">false</param>
<param
name="includeProperties">actionErrors.*,actionMessages.*,fieldErrors.*</param>
</result>
<result name="error" type="myJsonResult">
<param name="ignoreHierarchy">false</param>
<param
name="includeProperties">actionErrors.*,actionMessages.*,fieldErrors.*</param>
</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error" />
</global-exception-mappings>
<action name="ContactSearchJson"
class="com.afs.web.action.json.ContactSearchJsonAction">
<result type="myJsonResult" />
</action>
</package>
On Fri, Nov 28, 2014 at 10:04 AM, Dave Newton <[email protected]> wrote:
> What does the action in question look like, specifically, stuff
> related to the `searchCriteria` object?
>
> On Fri, Nov 28, 2014 at 10:29 AM, Burton Rhodes <[email protected]>
> wrote:
> > I have a simple json action that searches for a Contact in the system. I
> > am using a GET request with the following url:
> >
> >
> "ContactSearchJson.action?searchCriteria.searchStringContact=Doe&searchCriteria.categories=agent
> >
> > You'll notice I'm trying to set two variable in the object
> searchCriteria.
> > However, when the variables are set in the action only one variable is
> set,
> > but not both. If I remove either "searchStringContact" or "categories",
> > the remaining value will set fine.
> >
> > My assumption is it is setting the "searchCriteria.searchStringContact"
> > value, then when it comes across the "searchCriteria.categories" value it
> > overwrites the entire object so the only value that is set is
> "categories".
> >
> > My questions is, if this a bugor a feature in the json-plugin? Or am I
> > doing something wrong here?
> >
> > Thanks,
> > Burton
>
>
>
> --
> e: [email protected]
> m: 908-380-8699
> s: davelnewton_skype
> t: @dave_newton
> b: Bucky Bits
> g: davelnewton
> so: Dave Newton
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>