< o:form styleClass>使用MyFaces而不是Mojarra时未呈现 [英] <o:form styleClass> not rendered when using MyFaces instead of Mojarra
问题描述
我一直在使用JSF2.0 TomEE 1.7.3开发一个网站. 在我问的最后一个问题中:
I've been developing a website with JSF2.0 TomEE 1.7.3. In the last question I've asked :
我得到了建议,并决定从GlassFish(Mojarra)Faces迁移到myFaces,因为myFaces是TomEE的标准JSF实现.
I got advices and decided to migrate from GlassFish(Mojarra) Faces to myFaces, because myFaces is the standard JSF implementation of TomEE.
然后我意识到,如果我使用TomEE的默认myFaces,则"OmniFaces v1.8.3表单"不会使用"style"或"styleClass"呈现css类属性.在Mojarra上可以正常使用,但是现在我的HTML布局损坏了,我必须对其进行修复.
Then I realized that "OmniFaces v1.8.3 Form" is not rendering css class attribute with "style" nor "styleClass", if I use the default myFaces of TomEE. It worked fine with Mojarra, but now I get my HTML layout broken, and I have to fix it.
我使用"OmniFaces Form"的原因是,我真的想使用includeRequestParams="true"
功能,这在Mojarra和myFaces中都可以使用.
Reason I use "OmniFaces Form" is, I really want to use includeRequestParams="true"
feature, and this works in BOTH Mojarra and myFaces.
我的xhtml如下所示:
My xhtml looks like bellow:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:o="http://omnifaces.org/ui"
>
<h:body>
<ui:composition template="templates/common.xhtml">
<ui:define name="content">
<o:form prependId="false" styleClass="form-horizontal" includeRequestParams="true">
<!-- some inputText, labels, and buttons here -->
</o:form>
</ui:define>
</ui:composition>
</h:body>
</html>
我在HTML中得到的是:
What I get in HTML is:
<form id="j_id_1k" name="j_id_1k" method="post" action="/foo.xhtml">
class="form-horizontal"
未呈现.
我错过了什么吗? xmlns错误或已弃用?
还是仅仅是模块之间的不一致而我对此无能为力?
还是有等同于includeRequestParams
的东西?
Am I missing something? are the xmlns wrong or deprecated?
or is it just a inconsistency between modules and I cannot do anything about it?
or is there something equivalent to includeRequestParams
?
我已经尝试过使用javascript将CSS类附加到表单标签的方法(我知道这不是一个好方法):
I've tried something like this to attach css class to form tag with javascript (I know this is not a good approach):
(function() {
var forms = document.forms;
for (var i = 0; i < forms.length; i++){
if (forms[i].id !== "headerForm"){
forms[i].class = "form-horizontal";
}
}
})();
但是它并不能解决布局问题,可能是因为css样式附加到了表单内部的对象上,而不是表单本身(我正在使用css引导程序).
but it didn't fix the layout, maybe because css styles are attached to the objects INSIDE the form, not the form itself (I'm using css bootstrap).
请帮帮我!谢谢.
推荐答案
这是<o:form>
中的错误.最初 /a>从 UIForm
类扩展,但并未定义所有非常见属性.我已修复,它从 2.3-SNAPSHOT 中可用.
This was a mistake in <o:form>
. It initially extended from UIForm
class, but it doesn't have all non-common attributes definied. I fixed it to extend from HtmlForm
instead and now it works for me in MyFaces too. It's available in today's 2.3-SNAPSHOT.
这篇关于< o:form styleClass>使用MyFaces而不是Mojarra时未呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!