简体   繁体   English

RichFaces Ajax不起作用

[英]RichFaces ajax don't work

I am trying use the sample from showcase of commandButton. 我正在尝试使用commandButton展示柜中的示例。

But when I do this: 但是当我这样做时:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>Rich Teste</title>
    </h:head>
    <h:body>
        <h:outputStylesheet>
            form {
                background: #fee3ad
            }
        </h:outputStylesheet>
        <h:form id="iddoform" >
            <h:panelGrid columns="3">
                <h:outputText value="Nome:" />
                <h:inputText value="#{testeBean.nome}"/>
                <a4j:commandButton  value="Teste" render="iddoform:out" execute="@form" />
            </h:panelGrid>
           <br />
           <a4j:outputPanel id="out">
                <h:outputText value="Hello #{testeBean.nome} !"/>
           </a4j:outputPanel>
        </h:form>
        <br />
        <a4j:log /> 
    </h:body>
    </html>

It didn't work, so I changed to this: 它没有用,所以我改为:

  <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:f="http://java.sun.com/jsf/core">

    <h:outputStylesheet>
        form {
            background: #fee3ad
        }
    </h:outputStylesheet>

    <h:form id="iddoform">
        <h:panelGrid columns="3">
            <h:outputText value="Nome:" />
            <h:inputText value="#{testeBean.nome}" />
            <a4j:commandButton value="Teste"
                render="iddoform:out" execute="@form" />
        </h:panelGrid>
        <br />
        <a4j:outputPanel id="out">
            <h:outputText value="Hello #{testeBean.nome} !" />
        </a4j:outputPanel>
    </h:form>
    </html>
enter code here

And it works! 而且有效!

The change was to remove the head and body from html. 更改是从html删除了头部和身体。

My question is: 'Why doesn't work with head and body tags?'. 我的问题是: “为什么不适用于头部和身体标签?”。

PS: I am try with render="iddoform:out", :iddoform:out and out; PS:我尝试使用render =“ iddoform:out”,:iddoform:out and out; And i am try with immediate true too, but dont work. 我也尝试立即实现,但是不起作用。

When you say "it doesn't work" you have to say how are you expecting it to work. 当您说“它不起作用”时,您必须说您期望它如何起作用。

It's not the <h:head> and <h:body> that makes it not work, it's the immediate="true" . 不是它使<h:head><h:body>不能正常工作,而是immediate="true" It makes the button action be processed before the name can be set. 它可以在设置名称之前处理按钮动作。 You don't have it in your second example, that's why it works. 您的第二个示例中没有它,这就是它起作用的原因。

Also you don't have to use iddoform:out to point to the panel, just out is enough, the engine will find it. 同样,您也不必使用iddoform:out指向面板,只需将其显示out ,引擎就会找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM