jhipster client side pass entity filter to server side?

angular jhipster

1009 观看


538 作者的声誉

After reading http://www.jhipster.tech/entities-filtering/, I can get my jhipster generated applicaiton filter work on postman.

For example I can get right result on postman with: http://localhost:8080/api/requests?page=0&size=20&sort=model,asc&sort=id&id.in=20000,20001

my questions how can make it work on the generated angular client side app?

I saw that in the ../shared folder it has "request-util.ts". Inside it, there is parameter named "query" and "filter".

export const createRequestOption = (req?: any): BaseRequestOptions => {
const options: BaseRequestOptions = new BaseRequestOptions();
if (req) {
    const params: URLSearchParams = new URLSearchParams();
    params.set('page', req.page);
    params.set('size', req.size);
    if (req.sort) {
        params.paramsMap.set('sort', req.sort);
    params.set('query', req.query);
    params.set('filter', req.filter);

    options.params = params;
return options;


After reading JHipster: Filtering entities with criteria - intended Angular client-side approach I tried serveral ways to either pass a {} or [] to query or fitler. However, I cannot make it to work.

In the server side, log says: RequestResource.getAllRequests() with argument[s] = [RequestCriteria{}, Page request [number: 0, size 21, sort: happenDate: DESC]]

The "RequestCriteria{}" cound not get anything I passed in.

Anyone has idear how can I make it work? Thanks a lot.

作者: Maosheng Wang 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


538 作者的声誉


as a temp way, here is my current way to pass the filter from client to server:

compose a filter property for the paramater req object pass to model some.service.ts query(req?:any) function like this

 req.filter =  {
        'contactName.contains': "Smith"

and then change the ../shared folder request-util.ts file

if (req.filter) {
        for (const k in req.filter) {
            if (k) {
              params.append(k, req.filter[k]);

    // params.set('filter', req.filter);
作者: Maosheng Wang 发布者: 31.12.2017 08:53