public class WicketUtils extends Object
Constructor and Description |
---|
WicketUtils() |
Modifier and Type | Method and Description |
---|---|
static org.apache.wicket.markup.html.WebComponent |
appendMissingCss(org.apache.wicket.markup.html.WebComponent wc,
String... missingClassDef)
If model-data failed to load for the given component to be rendered, then can append a 'missing-data' class
Just a convenience method |
static String |
createPageLink(List<String> paramInclude,
List<String> paramIgnore,
String prefix,
org.apache.wicket.Request request,
String suffix)
Re-Create a link with specific params only; cleans by recreating link with required params only
|
static void |
feedback(List<Status> feedbackStatus,
org.apache.wicket.Component component)
|
static org.apache.wicket.Component |
find(org.apache.wicket.MarkupContainer parent,
String... s)
Find Component with Id in a given parent
|
static String |
generateJS(Class loaderClass,
Map<String,Object> properties,
String fileName)
This will generate something like the following in your HTML header:
|
static String |
getAbsoluteAppPath()
If Application hosted @ http://abc.com/appName/ then http://abc.com/appName/ will be returned.
|
static org.apache.wicket.ajax.AjaxRequestTarget |
getAjaxTarget(org.apache.wicket.Page page) |
static org.apache.wicket.protocol.http.RequestLogger.SessionData[] |
getLiveSessionInfo() |
static org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior |
getOnFieldErrorbehavior(org.apache.wicket.markup.html.WebMarkupContainer parent,
org.apache.wicket.markup.html.panel.FeedbackPanel formLevelFeedback)
Form Field validations @ a feild level ; where the fields can add this Behavior as long as they are decorated by a
Border (namely FormComponentFeedbackBorder ) |
static String |
getRequestUrl()
Get the complete Browser request URL
|
static <T extends org.apache.wicket.Component> |
getRoot(T component)
For any Wicket
Component get root (top-most parent MarkupContainer ). |
static org.apache.wicket.Session |
getSession(org.apache.wicket.Request request) |
static User |
getUser(javax.servlet.http.HttpServletRequest request)
Get
User from request. |
static User |
getUser(javax.servlet.http.HttpSession httpSession)
Get
User from request. |
static <U extends User> |
getUserFromSession(BasicSession bs,
Class<U> userTypeExpected)
When user is switching between multiple context, the session type or user type
may not match expected/intended type.
|
static <U extends User> |
getUserFromSession(org.apache.wicket.Request request,
Class<U> userTypeExpected)
When user is switching between multiple context, the session type or user type
may not match expected/intended type.
|
static String |
getUserId(BasicSession bs)
Deprecated.
Now supplied for util completeness and null check only. Use
BasicSession.getUserId() instead. |
static String |
getUserId(javax.servlet.http.HttpServletRequest request)
Get a String use id that is either a SessionID or
User 's id associated with the session (represented by the request). |
static String |
getUserId(javax.servlet.http.HttpSession httpSession)
Get a String use id that is either a SessionID or
User 's id associated with the session. |
static String |
getUserId(org.apache.wicket.Request request)
Get
User.getId() if available from Session else get the Session.getId() . |
static WebUserShell |
getWebUserShell(javax.servlet.http.HttpServletRequest request)
Get
WebUserShell from request. |
static WebUserShell |
getWebUserShell(javax.servlet.http.HttpSession httpSession)
Get
WebUserShell from request. |
static <S extends org.apache.wicket.Session> |
getWicketSession(javax.servlet.http.HttpServletRequest request,
Class<S> sessionType)
From a Standard
HttpServletRequest derive the existing Wicket Session. |
static <S extends org.apache.wicket.Session> |
getWicketSession(javax.servlet.http.HttpSession httpSession,
Class<S> sessionType)
From a Standard
HttpSession derive the existing Wicket Session. |
static void |
redirectExternal(String absolutePath,
org.apache.wicket.Component c)
Client redirect to an external URL.
|
static void |
renderResponse(String html,
org.apache.wicket.Component c)
Dumps the HTML on the client browser
|
public static String generateJS(Class loaderClass, Map<String,Object> properties, String fileName)
loaderClass
- as Class from where (class-path) the fileName will be pickedproperties
- as MapfileName
- as String, the name of the template file.public static <T extends org.apache.wicket.Component> T getRoot(T component)
Component
get root (top-most parent MarkupContainer
). if no parent, then it will return the component argument itself.component
- Component
(if any parent exists it will be of type MarkupContainer
)public static String getAbsoluteAppPath()
public static String getRequestUrl()
public static final org.apache.wicket.markup.html.WebComponent appendMissingCss(org.apache.wicket.markup.html.WebComponent wc, String... missingClassDef)
wc
- as WebComponent
missingClassDef
- as String varargs, missingClassDef[0] is an alternate CSS ddefinition overridepublic static org.apache.wicket.Component find(org.apache.wicket.MarkupContainer parent, String... s)
parent
- as parent/root components
- as id of Component to find; one can also specify as x,y,z. Will look for x in parent, y in x and then x in y.public static org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior getOnFieldErrorbehavior(org.apache.wicket.markup.html.WebMarkupContainer parent, org.apache.wicket.markup.html.panel.FeedbackPanel formLevelFeedback)
Border
(namely FormComponentFeedbackBorder
)parent
- formLevelFeedback
- public static org.apache.wicket.Session getSession(org.apache.wicket.Request request)
public static org.apache.wicket.protocol.http.RequestLogger.SessionData[] getLiveSessionInfo()
public static String getUserId(org.apache.wicket.Request request)
User.getId()
if available from Session else get the Session.getId()
.
If the session is not bound, it will bind it and force and Id out of it.
User.getId()
unlike BasicSession.getUserId()
public static String getUserId(javax.servlet.http.HttpServletRequest request)
User
's id associated with the session (represented by the request).request
- as HttpServletRequest
to derive the session and related infopublic static String getUserId(javax.servlet.http.HttpSession httpSession)
User
's id associated with the session.
BasicSession
one can override which id is used by overriding BasicSession.getUserId()
httpSession
- as HttpSession
to derive the session and related info@Deprecated public static String getUserId(BasicSession bs)
BasicSession.getUserId()
instead.BasicSession
BasicSession.getUserId()
public static <S extends org.apache.wicket.Session> S getWicketSession(javax.servlet.http.HttpServletRequest request, Class<S> sessionType)
HttpServletRequest
derive the existing Wicket Session. Useful for Web Service calls made during a Wicket Sessionrequest
- as HttpServletRequestpublic static <S extends org.apache.wicket.Session> S getWicketSession(javax.servlet.http.HttpSession httpSession, Class<S> sessionType)
HttpSession
derive the existing Wicket Session. Useful for Web Service calls made during a Wicket SessionhttpSession
- as HttpSessionpublic static <U extends User> U getUserFromSession(org.apache.wicket.Request request, Class<U> userTypeExpected)
userTypeExpected
- public static <U extends User> U getUserFromSession(BasicSession bs, Class<U> userTypeExpected)
userTypeExpected
- public static User getUser(javax.servlet.http.HttpServletRequest request)
User
from request.request
- as HttpServletRequest
User
public static User getUser(javax.servlet.http.HttpSession httpSession)
User
from request.httpSession
- as HttpSession
User
public static WebUserShell getWebUserShell(javax.servlet.http.HttpServletRequest request)
WebUserShell
from request.request
- as HttpServletRequest
WebUserShell
public static WebUserShell getWebUserShell(javax.servlet.http.HttpSession httpSession)
WebUserShell
from request.httpSession
- as HttpSession
WebUserShell
public static String createPageLink(List<String> paramInclude, List<String> paramIgnore, String prefix, org.apache.wicket.Request request, String suffix)
paramInclude
- as List of String params from requestparamIgnore
- as List of String params from request (will override if in conflict with included params)prefix
- as the Opening tag details to this link including protocl and domain name before the actual relative pathrequest
- as Request
suffix
- as suffix ending tag details to this linkpublic static void redirectExternal(String absolutePath, org.apache.wicket.Component c)
RestartResponseException
absolutePath
- as String representing the absolute path of the URLcontainer
- as Component
that calls this helper methodpublic static void renderResponse(String html, org.apache.wicket.Component c)
html
- as Stringcontainer
- as Component
that calls this helper methodpublic static org.apache.wicket.ajax.AjaxRequestTarget getAjaxTarget(org.apache.wicket.Page page)
Copyright © 2018. All rights reserved.