Package: RenderContext
RenderContext
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getPathParams(SiteNode) |
|
|
|
|
|
||||||||||||||||||||
getQueryParam(String) |
|
|
|
|
|
||||||||||||||||||||
setDynamicNodeProperty(Key, Object) |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.ui;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Optional;
31: import it.tidalwave.util.Key;
32: import it.tidalwave.northernwind.core.model.Request;
33: import it.tidalwave.northernwind.core.model.RequestContext;
34: import it.tidalwave.northernwind.core.model.ResourcePath;
35: import it.tidalwave.northernwind.core.model.SiteNode;
36:
37: /***********************************************************************************************************************
38: *
39: * @author Fabrizio Giudici
40: *
41: **********************************************************************************************************************/
42: public interface RenderContext
43: {
44: @Nonnull
45: public Request getRequest();
46:
47: @Nonnull
48: public RequestContext getRequestContext();
49:
50: /*******************************************************************************************************************
51: *
52: * Sets a dynamic node property. These properties can be associated to the current {@link SiteNode}, created in
53: * a dynamic fashion while processing the {@link Request} and available only in the {@link RequestContext}.
54: *
55: * This property will be made available by {@link #getNodeProperties()}, which e.g. is used by the
56: * {@code $nodeProperty(...)$} macro.
57: *
58: * @param key the property key
59: * @param value the property value
60: *
61: ******************************************************************************************************************/
62: public default <T> void setDynamicNodeProperty (@Nonnull final Key<T> key, @Nonnull final T value)
63: {
64: getRequestContext().setDynamicNodeProperty(key, value);
65: }
66:
67: /*******************************************************************************************************************
68: *
69: * Returns a query parameter.
70: *
71: * @param name the name of the parameter
72: * @return the value
73: *
74: ******************************************************************************************************************/
75: @Nonnull
76: public default Optional<String> getQueryParam (@Nonnull final String name)
77: {
78: return getRequest().getParameter(name);
79: }
80:
81: /*******************************************************************************************************************
82: *
83: * Returns the path parameters.
84: *
85: * @param siteNode the node that needs the parameters
86: * @return the path parameters
87: *
88: ******************************************************************************************************************/
89: @Nonnull
90: public default ResourcePath getPathParams (@Nonnull final SiteNode siteNode)
91: {
92: return getRequest().getPathParams(siteNode);
93: }
94: }
95: