相关疑难解决方法(0)

何时使用<ui:include>,标记文件,复合组件和/或自定义组件?

我最近开始使用带有Facelets的JSF 2.0,并且对于了解<ui:include>Facelets 1.x提供的现有和其他模板技术的新复合组件感到困惑.

这些方法有什么区别?从功能上看,它们似乎提供了相同的:<ui:param>vs <cc:attribute>,<ui:insert>+ <ui:define>vs标记文件,重用现有模板.除了复合组件的语法和清晰的接口规范之外还有什么吗?性能会有所不同?

facelets tagfile custom-component composite-component jsf-2

95
推荐指数
1
解决办法
5万
查看次数

JSF不呈现自定义HTML标记属性

我想在登录表单中添加一些iOS特定的标记属性.如果我查看我的网页源代码,那么属性autocorrect,autocapitalize和spellcheck就不存在了.这是什么原因?我正在使用JSF 2.x.

<h:inputText id="user-name" forceId="true" value="#{login.username}" style="width:120px;"
    autocorrect="off" autocapitalize="off" spellcheck="false" />
Run Code Online (Sandbox Code Playgroud)

html jsf renderer custom-attributes

27
推荐指数
1
解决办法
2万
查看次数

向JSF 2.0 UIInput组件添加自定义属性(HTML5)支持

我正在尝试编写一个渲染器来处理组件placeholder上的属性<h:inputText>.在阅读了JSF 2.0之后,我走向了这条路径,剥离了所需的HTML5属性,看起来是正确的.这是我的自定义渲染器

public class InputRenderer extends com.sun.faces.renderkit.html_basic.TextRenderer{

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) 
    throws IOException {
        System.out.println("Rendering :"+component.getClientId());

        String placeholder = (String)component.getAttributes().get("placeholder");
        if(placeholder != null) { 
            ResponseWriter writer = context.getResponseWriter();
            writer.writeAttribute("placeholder", placeholder, "placeholder");
        }

        super.encodeBegin(context, component);

    }


    @Override
    public void decode(FacesContext context, UIComponent component) {
        super.decode(context, component);
    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) 
    throws IOException {
        super.encodeEnd(context, component);
    }
}
Run Code Online (Sandbox Code Playgroud)

此渲染器在faces config中注册为

 <render-kit>
    <renderer>
        <component-family>javax.faces.Input</component-family>
        <renderer-type>javax.faces.Text</renderer-type>
        <renderer-class>com.example.renderer.InputRenderer</renderer-class>
    </renderer>
</render-kit> …
Run Code Online (Sandbox Code Playgroud)

html jsf html5 jsf-2 mojarra

11
推荐指数
2
解决办法
1万
查看次数

h:inputText - jsf不呈现占位符

我想创建一个landingPage,我想通过jsf 2.0和Primefaces 3.5将数据保存在我的数据库中

我的页面*.xhtml页面如下所示:

在此输入图像描述

但是,我想让它看起来像我的HTML页面:

在此输入图像描述

除了CSS我的h:inputText应该包含一个占位符.我的代码看起来像这样:

<h:form class="homepage_invitee_form" action="" method="POST">
    <h:inputText name="email" placeholder="Email Address"
                 id="email_address_new" type="text placeholder" />
    <br />
    <h:inputText name="firstName" placeholder="First Name"
                 id="firstname_new" type="text placeholder" />
    <h:inputText name="lastName" placeholder="Last Name"
                 id="lastname_new" type="text placeholder" />
    <br />
    <h:button value="Request Invitation" type="submit" class="btn btn-primary opal_btn"
              id="submit_form_new" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

如您所见,占位符属性未呈现.我真的很感激如何正确地渲染它.

UPDATE

我的HTML代码如下所示:

<form class="homepage_invitee_form" action="" method="POST">
    <input name="email" placeholder="Email Address" id="email_address_new" type="text placeholder"><br>
    <input name="firstName" placeholder="First Name" id="firstname_new" type="text placeholder">
    <input name="lastName" placeholder="Last Name" id="lastname_new" type="text placeholder"><br> 
    <button type="submit" class="btn btn-primary …
Run Code Online (Sandbox Code Playgroud)

html css java jsf primefaces

7
推荐指数
2
解决办法
2万
查看次数

InputText组件中的默认文本(占位符)

在此输入图像描述

我想在JSF/Primefaces inputText组件中显示默认的信息性文本.

  • 当用户单击"文本"字段时,此文本应消失.
  • 当他在没有打字的情况下点击外面时出现.
  • 如果用户提交的表单没有任何值,则不应将此默认值设置为Bean的属性.

我知道在ManagedBean中将默认值设置为BeanProperty会有效,但我不希望这样.
如果可能的话,请建议任何JQuery调整.
如果此问题是重复,请将我重定向到问题.

jquery jsf placeholder primefaces jsf-2

5
推荐指数
1
解决办法
8766
查看次数

禁用浏览器密码保存重定向

我试图跳过浏览器提示以保存我的登录表单的密码.

我已经检查了这个问题,并添加了autocomplete ="off"属性(在表单和字段上).

只需导航到另一个页面就可以了.但是,当我使用?faces-redirect=true(在我的主页按钮)时,我得到提示.

admin.xhtml:

<h:form id="form" autocomplete="off">
    <p:growl id="growl" showDetail="true" sticky="false" life="3000" />  
    <p:layout fullPage="true">          
        <p:layoutUnit position="center" >
            <p:panel id="loginPanel" visible="#{not admin.loggedIn}">
                <h:panelGrid columns="2" cellpadding="5">
                    <f:facet name="header">
                        <h:outputLabel value="Administration" />
                    </f:facet>  

                    <h:outputLabel for="username" value="Username:" />
                    <p:inputText id="username" value="#{admin.username}" required="true" autocomplete="off" label="username" />

                    <h:outputLabel for="password" value="Password:" />
                    <p:password id="password" value="#{admin.password}" required="true" autocomplete="off" label="password" />

                    <f:facet name="footer">
                        <p:commandButton value="Login" update="growl loginPanel logoutPanel" 
                        process="loginPanel" actionListener="#{admin.login}" />
                    </f:facet>  
                </h:panelGrid>
            </p:panel>
        </p:layoutUnit>     
        <p:layoutUnit position="north" size="85">
            <p:panel id="logoutPanel">
                <p:commandButton …
Run Code Online (Sandbox Code Playgroud)

browser jsf primefaces jsf-2.2

5
推荐指数
0
解决办法
1150
查看次数