3

I have a template in JSF, this template have a button whose action must be different for each page that will use this template. I wonder if there is any way to set only a part of that action. Eg In the template, I have the following attribute on the button:

disabled = "#{managedBeanTemplate.EditMode}"

However, for each page that will use this template, it should replace ONLY the part where it says managedBeanTemplate, thus:

disabled = "#{managedBeanProduct.EditMode}"
disabled = "#{managedBeanSales.EditMode}"

Is there any way to do this?

I know there is the ui:param to replace parts of the xhtml, but i can't nest in the template using something like this:

disabled = "#{#{managedBeanName}.EditMode}"

in the template, and then

<ui:param name="managedBeanName" value="managedBeanProduct"/>

in the page that uses the template.

4

2 回答 2

0

you would be better served having method that takes a parameter. by having the template construct the back references to the server side you are creating a maintainance footprint where it should not be. replace the references with a method that abstracts away the logic of whether the component is disabled/rendered/etc.

ultimately the UX should not care "why", just whether it has to render a compoenent a certain way.

于 2014-10-27T21:07:20.407 回答
0

我在这里找到了答案: facelets:将 bean 名称与 ui:param 传递给操作属性 我可以在模板中执行类似的操作:

disabled = "#{managedBeanName['EditMode']}"

然后,我可以简单地通过 ui:param 设置“managedBeanName”

于 2013-04-30T11:12:36.527 回答