For now I've got it working. Is there a better way of executing the
action and returning the correct page?
final ObjectAdapter serviceAdapter =
getServiceAdapter(SearchService.class.getName());
final ObjectAction action =
serviceAdapter.getSpecification().getObjectAction("find");
ActionModel actionModel = ActionModel.create(serviceAdapter,
action);
List<ActionParameterMemento> parametersList =
actionModel.primeArgumentModels();
AdapterManager am = (AdapterManager)getPersistenceSession();
for (ActionParameterMemento actionParameterMemento :
parametersList)
{
ScalarModel arg =
actionModel.getArgumentModel(actionParameterMemento);
switch (actionParameterMemento.getNumber())
{
case 0:
arg.setObject(am.adapterFor(this.query));
break;
case 1:
if(this.preference != null)
{
arg.setObject(am.adapterFor(SearchService.Type.valueOf(this.preference)));
}
break;
case 2:
arg.setObject(am.adapterFor(boost));
break;
default:
break;
}
}
ObjectAdapter resultAdapter = action.execute(serviceAdapter,
actionModel.getArgumentsAsArray(), InteractionInitiatedBy.USER);
ActionResultResponse resultResponse =
ActionResultResponseType.COLLECTION.interpretResult(actionModel, null,
resultAdapter);
resultResponse.getHandlingStrategy().handleResults(this,
resultResponse);
On 12/21/2015 09:10 AM, Erik de Hair wrote:
Hi,
I'm trying to create a generic search component that should show up in
the footer bar. Creating the component itself is not a problem but
returning the results is. The component is calling a service like this:
final SearchService searchService = lookupService(SearchService.class);
SortedSet<SearchResult> results = searchService.find(this.query, null,
1);
I was thinking about returning a StandaloneCollectionPage or ViewModel
by using ActionResultResponseType but I can't figure out to create the
model right. So how to set the response page with the right parameters?
Thanks,
Erik