- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- jakarta.faces.component.UIParameter
-
- org.omnifaces.component.output.Param<T>
-
- org.omnifaces.component.output.PathParam<T>
-
- Type Parameters:
T
- The type of the value.
- All Implemented Interfaces:
PartialStateHolder
,StateHolder
,TransientStateHolder
,ValueHolder
,ComponentSystemEventListener
,FacesListener
,SystemEventListenerHolder
,EventListener
,ParamHolder<T>
public class PathParam<T> extends Param<T>
The<o:pathParam>
is a component that extends the OmniFacesParam
to supportMultiViews
feature ofFacesViews
. It is done by rendering the supplied parameters of such components as<h:link>
and<h:button>
among others as path parameters and not as query parameters as otherwise will be produced by<o:param>
and<f:param>
tags.The component has built-in support for a
Converter
to convert the supplied value to string by usual means via theconverter
attribute of the tag, or the nested<f:converter>
tag, or just automatically if a converter is already registered for the target class via@FacesConverter(forClass)
.This component doesn't support returning encoded output of its children as parameter value in case no value is present. This feature is provided by
Param
component instead.Also, the name attribute must not be specified for this component as it already evaluates to a predefined one.
This component is used to create bookmarkable URLs via standard outcome target components that take into account
<o:pathParam>
tags nested in the components. The path parameters will be rendered in the order they were declared for a view id that is defined as a multi view and if the view was not defined as a multi view then they won't be rendered at all. Additionally, declaring path parameters for a non-multi view will be logged as a warning and a faces warning message will be added for any stage different fromProduction
.In the following example the link to the multi view page will be rendered with two path parameters:
<h:link value="Link" outcome="multiview-supported-path"> <o:pathParam value="first" /> <o:pathParam value="second" /> </h:link>
The code above will be rendered as:<a id="..." name="..." href="/context-path/multiview-supported-path/first/second">Link</a>
. The path parameters will be available via@Inject @Param(pathIndex=0) private String first;
and@Inject @Param(pathIndex=1) private String second;
the usual way.- Since:
- 3.6
- Author:
- Sergey Kuntsel
- See Also:
FacesViews
,FacesViewsViewHandler.getBookmarkableURL(FacesContext, String, java.util.Map, boolean)
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_TYPE
The component type, which is "org.omnifaces.component.output.PathParam".static String
PATH_PARAM_NAME_ATTRIBUTE_VALUE
The predefined value of thename
attribute of this component.-
Fields inherited from class jakarta.faces.component.UIParameter
COMPONENT_FAMILY
-
Fields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
-
-
Constructor Summary
Constructors Constructor Description PathParam()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
Returns the name of the parameter.String
getValue()
Returns the value of the parameter asString
.void
setName(String name)
-
Methods inherited from class org.omnifaces.component.output.Param
encodeChildren, getConverter, getLocalValue, getRendersChildren, setConverter
-
Methods inherited from class jakarta.faces.component.UIParameter
getFamily, isDisable, setDisable, setValue
-
Methods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class jakarta.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.faces.component.ValueHolder
setValue
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The component type, which is "org.omnifaces.component.output.PathParam".- See Also:
- Constant Field Values
-
PATH_PARAM_NAME_ATTRIBUTE_VALUE
public static final String PATH_PARAM_NAME_ATTRIBUTE_VALUE
The predefined value of thename
attribute of this component.- See Also:
- Constant Field Values
-
-
Method Detail
-
getValue
public String getValue()
Description copied from interface:ParamHolder
Returns the value of the parameter asString
. If the converter is set, or if any converter is available byApplication.createConverter(Class)
, passing the value's class, then return the result ofConverter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)
, otherwise return theObject.toString()
of the value.- Specified by:
getValue
in interfaceParamHolder<T>
- Specified by:
getValue
in interfaceValueHolder
- Overrides:
getValue
in classParam<T>
- Returns:
- The value of the parameter as
String
. - See Also:
Converter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)
-
setName
public void setName(String name)
- Overrides:
setName
in classUIParameter
-
getName
public String getName()
Description copied from interface:ParamHolder
Returns the name of the parameter.- Specified by:
getName
in interfaceParamHolder<T>
- Overrides:
getName
in classUIParameter
- Returns:
- The name of the parameter.
-
-