All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.rest.widget.QueryMenuItem Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.rest.widget;

import org.apache.juneau.rest.*;
import org.apache.juneau.rest.converters.*;

/**
 * Widget that returns a menu-item drop-down form for entering search/view/sort arguments.
 *
 * 

* The variable it resolves is "$W{QueryMenuItem}". * *

* This widget is designed to be used in conjunction with the {@link Queryable} converter, although implementations * can process the query parameters themselves if they wish to do so by using the {@link RequestQuery#getSearchArgs()} * method to retrieve the arguments and process the data themselves. * *

* An example of this widget can be found in the PetStoreResource in the examples that provides * search/view/sort capabilities against the collection of POJOs: *

* @RestMethod( * name=GET, * path="/", * widgets={ * QueryMenuItem.class, * }, * htmldoc=@HtmlDoc( * navlinks={ * "up: ...", * "options: ...", * "$W{QueryMenuItem}", * "$W{ContentTypeMenuItem}", * "$W{StyleMenuItem}", * "source: ..." * } * ), * converters=Queryable.class * ) * public Collection<Pet> getPets() { *

* *

* It renders the following popup-box: *
* *

* Tooltips are provided by hovering over the field names. *
* *

* When submitted, the form submits a GET request against the current URI with special GET search API query parameters. *
(e.g. "?s=column1=Foo*&v=column1,column2&o=column1,column2-&p=100&l=100"). *
The {@link Queryable} class knows how to perform these filters against collections of POJOs. */ public class QueryMenuItem extends MenuItemWidget { /** * Returns CSS for the tooltips. */ @Override public String getStyle(RestRequest req) throws Exception { return super.getStyle(req) + "\n" + loadStyle("QueryMenuItem.css"); } @Override /* MenuItemWidget */ public String getLabel(RestRequest req) throws Exception { return "query"; } @Override /* MenuItemWidget */ public String getContent(RestRequest req) throws Exception { return loadHtml("QueryMenuItem.html"); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy