Package io.keikai.jsp
Class SmartUpdateBridge.Builder
- java.lang.Object
-
- io.keikai.jsp.SmartUpdateBridge.Builder
-
- Enclosing class:
- SmartUpdateBridge
public static final class SmartUpdateBridge.Builder extends Object
A builder utils to create an instance of SmartUpdateBridge to use.For example,
Map jsonResult = SmartUpdateBridge.Builder.create(servletContext, req, resp) .withComponent(spreadsheet -> doAnything(spreadsheet)) // Optional .withBook(book -> { Sheet sheet = book.getSheetAt(0); if ("reset".equals(action)){ handleReset(sheet); } else if("check".equals(action)){ handleCheck(sheet); } }).build();
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map
build()
Builds the Keikai's response JSON data in Map format.Map
build(Map result)
Builds the Keikai's reponse JSON data in Map format and merge with the give custom data.static SmartUpdateBridge.Builder
create(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Creates the builder instance.static SmartUpdateBridge.Builder
create(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, Map data)
Creates the builder instance withServletRequest.getReader()
data, which is passed from Browser'swindow.fetch API.SmartUpdateBridge.Builder
withBook(Consumer<Book> consumer)
Processes with the Book instance.SmartUpdateBridge.Builder
withComponent(Consumer<Spreadsheet> consumer)
Processes with the Spreadsheet component.
-
-
-
Method Detail
-
create
public static SmartUpdateBridge.Builder create(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Creates the builder instance.- Parameters:
servletContext
-req
-resp
-- Returns:
-
create
public static SmartUpdateBridge.Builder create(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, Map data)
Creates the builder instance withServletRequest.getReader()
data, which is passed from Browser'swindow.fetch API.For example at client side,
// The browser's fetch API will go through HTTPServletRequest's body data, // not HTTPServletRequest's getParameters(). fetch("/action", { headers: { 'Content-Type': 'application/json', }, method: 'POST', body: JSON.stringify(kkjsp.prepare('myzss', {action: action})) // prepares with Keikai's request data }) .then(function (response) {return response.json()}) .then(kkjsp.process) // Keikai JSP response processor .then(handleAjaxResult); // User defined function
- Parameters:
servletContext
-req
-resp
-data
- the request body data, which is used for Browser'swindow.fetch API.- Returns:
- See Also:
ServletRequest.getReader()
-
withComponent
public SmartUpdateBridge.Builder withComponent(Consumer<Spreadsheet> consumer)
Processes with the Spreadsheet component. (Optional)- Parameters:
consumer
-- Returns:
-
withBook
public SmartUpdateBridge.Builder withBook(Consumer<Book> consumer)
Processes with the Book instance. (Optional)- Parameters:
consumer
-- Returns:
-
build
public Map build()
Builds the Keikai's response JSON data in Map format.- Returns:
-
-