JSF: Creating aliases for properties in backing bean
Asked Answered
P

3

6

I am referring to pretty deep object hierarchies with pretty cryptic names in EL as in #{myBean.configBaseStack.excludeMethodFromAccounting.method.TimeoutBehaviorEnabled}.

I would like to point to this very same property through an alias like in:

<x:alias name="m" value="#{myBean.configBaseStack.excludeMethodFromAccounting.method" />
<h:inputText value="#{m.TimeoutBehaviorEnabled}" />

I guess one way to accomplish this would be to create these aliases in the backing bean, but I'd rather leave that to the template.

How to accomplish this in template/facelet level?

Primateship answered 3/1, 2011 at 15:30 Comment(0)
Z
9

I think you can use <ui:param> to accomplish this:

<ui:param name="m" value="#{myBean.configBaseStack.excludeMethodFromAccounting.method}"/>

Then you can use it like this on the same page:

<h:inputText value="#{m.TimeoutBehaviorEnabled}" />
Zephan answered 3/1, 2011 at 16:1 Comment(2)
I knew this was simple. I checked f:param and f:attribute but didn't realize there was this :) Seems to work, thanks!Primateship
Read section "<c:set> vs <ui:param>" here: stackoverflow.com/questions/3342984Orff
W
1

You could probably use the JSTL-equivalent set tag for this (using the var and value attributes).

Watery answered 3/1, 2011 at 15:55 Comment(1)
That would be possible, but it would lock the relation. Using ui:param as Shervin suggests allows using properties more flexibly. Good suggestion, though.Primateship
T
0

For all i know aliasing is not not supported in jsf, using the standard components that is.

Tungstite answered 3/1, 2011 at 15:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.