f:param
私のページ ナビゲーションのほとんどは get リクエストを使用しており、使用するために内部h:commandButton
またはチェック属性をincludeViewParams
使用してクエリ文字列パラメーターとしてパラメーターを含める必要があるフォームがありますUIViewParameter
。
これにはビューで定義されたすべてのパラメーターが含まれるため、使用したくありませんincludeViewParams
。コマンド コンポーネントの子として提供されるものを使用したいだけです。
<h:form>
<p:inputText value="#{bean.value1}"/>
<p:selectOneMenu value="#{bean.value2}"/>
<p:commandButton action="#{utilBean.performActionParams(outcome)}">
<f:param name="key1" value="#{bean.value1}"/>
<o:param name="key1" value="#{bean.value2}" converter="#{bean.converter}/>
</p:commandButton>
</h:form>
public String performActionParams(final String outcome)
{
final UriBuilder uriBuilder = UriBuilder.fromPath(outcome);
final FacesContext context = FacesContext.getCurrentInstance();
final UIComponent component = UIComponent.getCurrentComponent(context);
for (final UIComponent child : component.getChildren())
if (child instanceof UIParameter)
{
final UIParameter param = (UIParameter) child;
if (!param.isDisable() && !StringUtils.isBlank(param.getName()))
{
final Object value = param.getValue();
if (value != null)
uriBuilder.queryParam(param.getName(), value);
}
}
return uriBuilder.build().toString();
}
h:link
このロジックはそれほど複雑ではありませんが、および と同じロジックのように見えるため、非常に冗長に見えますh:button
。
それで、誰かがこのロジックが実装されている場所を知っていますか?