来自 jsp:include 的 JSF 1.2 自定义组件
在开始回答我的问题之前,先说明一下我的不幸的限制:
- 我使用的是 JSF 1.2,而不是 2;所以没有复合组件。
- 我使用 JSP 代替 Facelets 进行渲染;所以这些复合组件也没有。
- 我不允许使用任何第三方标签库(richFaces、iceFaces 等)。
这些限制是一成不变的。
现在开始我的问题。目前,我们有一个 JSP subview
来处理创建地址。有很多 javascript 与此相关,还有一个支持 bean。该页面从未被直接使用。相反,它是使用
包含的。
但是,我希望能够更改几个属性。例如,是否需要县,我们目前是否正在进行地址清理等。为了做到这一点,使用自定义组件是有意义的(我认为?)。但是,我不太确定执行此操作的最佳方法。
如果可以的话,我会简单地将这个 JSP 转换成一个复合组件并使用它。然而,基于我的限制,这并不是一个真正的选择。
我有什么选择?如果不是涉及大量的 javascript,这不会那么困难。我知道我的解释含糊不清;然而,我更多的是寻求指导而不是直接答案。我在 google 上搜索过诸如使用 javascript 的自定义 JSF 1.x 组件等内容。但是,我没有找到很多好的文章。
提前致谢。
Before I get started with my question, here are my unfortunate limitations:
- I'm using JSF 1.2, not 2; so no composite component.
- I'm using JSP for rendering instead of facelets; so none of those composite components either.
- I'm not allowed to use any 3rd-party tag libraries (richFaces, iceFaces, etc.)
These limitations are set in stone.
Now moving onto my question. Currently, we have a JSP subview
which handles creating an address. There is a lot of javascript that goes along with this, along with a backing bean. This page is never used directly. Instead, it's included using a <jsp:include />
.
However, there are several attributes that I want to be able to change. For instance, is county required, are we currently doing address scrubbing, etc. In order to do this, it would make sense to use a custom component (I think?). However, I'm not really sure the best way to do this.
If I could, I would simply turn this JSP into a composite component and be done with it. However, that's not really an option based on my limitations.
What are my options? This wouldn't be so difficult if it weren't for the amount of javascript involved. I know my explanation was vague; however, I'm looking more for guidance than a direct answer. I've googled for things such as custom JSF 1.x components with javascript, etc. I haven't found many good articles, however.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建 JSP 标记文件。
/WEB-INF/tags/foo.tag
按如下方式声明和使用它(无需额外的 XML 配置):
请注意,JSTL 在这里也是一个“查看构建时间”标签,就像 Facelets 中一样。另请注意,您不能使用
#{}
来引用 JSP 标记属性。Create a JSP tag file.
/WEB-INF/tags/foo.tag
Declare and use it as follows (no additional XML configuration necessary):
Note that JSTL is also here a "view build time" tag like as in Facelets. Also note that you can't use
#{}
to reference JSP tag attributes.