JSF 1.2 自定义组件 - 来自支持 Bean 的主体内容
我正在使用 JSF 1.2 开发自定义组件。 我的标记类扩展了 UIComponentELTag
并具有 ValueExpression
类型的变量。 这些值是从标签的相应属性中设置的(使用 setProperties 函数),例如,
<sr:show name="#{backingBean.name}" ...> #{backingBean.mainContent}</sr:show>
当我尝试获取标签的 bodyContent 作为绑定值时,我陷入了困境。 这就是我已经进行的程度:
public int doAfterBody() throws JspException{
if(bodyContent!=null) {
String body = bodyContent.getString();
FacesContext context = FacesContext.getCurrentInstance();
UIComponent component = super.findComponent(context);
MyComp myComp= (MyComp) component;
myComp.setMain(body);
}
bodyContent.clearBody();
return SKIP_BODY;
}
如果标记的主体不包含绑定值,则此代码可以正常工作。 我想检查主体是否具有绑定值,然后从 bean 设置该值。
在 JSF 1.1 中,我使用 isValueReference(body)
检查了这一点。 如何在 JSF 1.2 中实现这一目标? 我在任何地方都找不到任何将正文内容作为绑定值的示例。
I am developing a custom component using JSF 1.2. My tag class extends UIComponentELTag
and has variables of type ValueExpression
. The values for these are getting set from the corresponding attributes of the tag (using setProperties
function), for example
<sr:show name="#{backingBean.name}" ...> #{backingBean.mainContent}</sr:show>
I am stuck when I try to get the bodyContent of the tag as a binding value.
This is how far I have proceeded:
public int doAfterBody() throws JspException{
if(bodyContent!=null) {
String body = bodyContent.getString();
FacesContext context = FacesContext.getCurrentInstance();
UIComponent component = super.findComponent(context);
MyComp myComp= (MyComp) component;
myComp.setMain(body);
}
bodyContent.clearBody();
return SKIP_BODY;
}
If the body of the tag does not contain binding value, this code works fine. I want to check if the body has binding value and then set the value from the bean.
In JSF 1.1, I checked this using isValueReference(body)
. How do I achieve this in JSF 1.2? I could not find any examples of getting the body content as binding value anywhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不简单地添加另一个变量(例如“内容”)并将其绑定到您想要呈现的正文文本?
或者简单地说:
渲染全部。
Why not simply add another variable e.g. "contents" and bind that to the body text you want to render?
Or simply:
and render the whole lot.