OK, +1 on that.

For updating of the ElasticSearch data, you could use the 1.10.0 lifecycle
events.

On 23 December 2015 at 13:56, Erik de Hair <[email protected]> wrote:

> Hi Dan,
>
> On 12/23/2015 02:04 PM, Dan Haywood wrote:
>
>> Hi Erik,
>>
>> Sorry not to get back to you before now.
>>
>> As you've probably realized, there's no particularly clean API here to
>> leverage, and what you've written is isn't too far off the mark from what
>> I
>> would have written.
>>
>> In the Wicket viewer itself the ActionPanel uses the ActionModel (which
>> you
>> discovered), and it invokes the action through the model  [1], ie:
>>
>>              final ObjectAdapter resultAdapter =
>> getActionModel().executeHandlingApplicationExceptions();
>>
> In the mean time I was using the following (a bit more generic) code
>
> ObjectAdapter resultAdapter =
> actionModel.executeHandlingApplicationExceptions();
> ActionResultResponse resultResponse =
> ActionResultResponseType.determineAndInterpretResult(actionModel, null,
> resultAdapter);
> resultResponse.getHandlingStrategy().handleResults(this, resultResponse);
>
> This way I don't have to change the Wicket component if the return type of
> the action changes (and that's what I did).
>
> It was hard to find out but it's nice to see it work finally!
>
> The search service is calling a Elasticsearch-engine. I saw a question
> about that on the mailing list. It's working now but I have to implement
> the updating of the objects.
>
>
>> Otherwise, looks ok.
>>
>> Thx
>> Dan
>>
>>
>> [1]
>>
>> https://github.com/apache/isis/blob/ef96cc80fe89290d2be79f831eb354dc0d7f886c/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/actions/ActionPanel.java#L257
>>
>>
>>
>>
>>
>> On 22 December 2015 at 12:10, Erik de Hair <[email protected]> wrote:
>>
>> 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
>>>>
>>>>
>>>
>

Reply via email to