Yes, I was just going to suggest this...

At least in RichFaces a4j (which seems to be the baseline for JSF
2.0), prefixing your identifier with ":" makes it an absolute path to
the component rather than a relative path.


On Mon, Jun 28, 2010 at 11:57 AM, Bytecode <bytec...@me.com> wrote:
> Werner,
>
> Thanks for the reply. I was able to solve the problem by replacing
>
>   <f:ajax execute="user-name password" render="out" />
>
> with
>
>   <f:ajax execute="user-name password" render=":out" />
>
> In other words, I changed "out" with ":out" and JSF was able to render the 
> out component
> that was placed outside the h:form.
>
> Regards
>
> On 27/06/2010, at 8:08 AM, Werner Punz wrote:
>
>> You need to write following code:
>>
>> <p><h:outputText id="out"  value="#{user.greeting}"  /></p>
>>       <h:form id="form1">
>>               <h:inputText value="#{user.name}"  id="user-name"  />
>>               <p><h:inputSecret value="#{user.password}"  id="password"  
>> /></p>
>>               <p>
>>               <h:commandButton value="Login"  id="login-button"
>>                       onclick="jsf.ajax.request(this,event,{execute:'form1', 
>> render:'out'}); return false;"">
>>
>>               </h:commandButton>
>>               </p>
>>       </h:form>
>> Thats it, but as I said this definitely works for the latest trunk,
>> I cannot gurantee that it works on the 2.0.0 code.
>>
>> Btw. there is theoretically another way you could use render @all in f:ajax 
>> that would replace the entire body, not really very ajaxy.
>>
>> Werner
>>
>>
>> Am 26.06.10 03:27, schrieb Bytecode:
>>> In other words, I want to make the following code work:
>>>
>>> |<?xml version="1.0"  encoding="ISO-8859-1"  ?>
>>> <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
>>>           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>>> <html xmlns="http://www.w3.org/1999/xhtml";
>>>      xmlns:h="http://java.sun.com/jsf/html";
>>>      xmlns:f="http://java.sun.com/jsf/core";>
>>> <h:head>
>>>      <title>Welcome</title>
>>> </h:head>
>>>
>>> <h:body>
>>>          <p><h:outputText id="out"  value="#{user.greeting}"  /></p>
>>>      <h:form id="form1">
>>>              <h:inputText value="#{user.name}"  id="user-name"  />
>>>              <p><h:inputSecret value="#{user.password}"  id="password"  
>>> /></p>
>>>              <p>
>>>              <h:commandButton value="Login"  id="login-button">
>>>                      <f:ajax execute="user-name password"  render="out"  />
>>>              </h:commandButton>
>>>              </p>
>>>      </h:form>
>>> </h:body>
>>>
>>> </html>|
>>>
>>>
>>> On 26 Jun, 2010,at 05:13 AM, Werner Punz <werner.p...@gmail.com> wrote:
>>>
>>>> Yes you can use the direct javascript api jsf.ajax.request instead of
>>>> ajax then you can use full identifiers.
>>>>
>>>> <h:commandButton value="Login" id="login-button">
>>>> > <f:ajax execute="user-name password" render="out" />
>>>> > </h:commandButton>
>>>> would become
>>>>
>>>> <h:commandButton value="Login" id="login-button"
>>>> onclick="jsf.ajax.request(this,event,{execute:'@this',
>>>> render:'form1:out'});return false;">
>>>> </h:commandButton>
>>>>
>>>> As you can see the render now is mapped to the full client identifier
>>>> form1:out
>>>>
>>>> That way you can make render submits outside of your form.
>>>>
>>>> However, I have to recommend to update to the latest trunk or the soon
>>>> hopefully to be released myfaces 2.0.1 if you want to do cross form
>>>> submits or submits with renders outside of your current form.
>>>>
>>>> I did a load of improvement especially in this area for the scripts so
>>>> that cases like updating a cross form element does not cause problems
>>>> anymore with other forms where the element might be embedded or which
>>>> has another form embedded :-)
>>>>
>>>> Here is a code snippet from one of my testing cases dealing exactly with
>>>> what you want to achieve:
>>>>
>>>> http://www.pastebin.org/358867
>>>>
>>>> Have in mind that all this works in the current trunk (and soon in
>>>> 2.0.1), but the 2.0.0 codebase and also Mojarra has some limitations.
>>>> (mostly if you update elements which embed forms, or in case of MyFaces
>>>> 2.0.0 also if you update elements within another form than the issuing
>>>> one)
>>>>
>>>>
>>>>
>>>> Werner
>>>>
>>>>
>>>> Am 25.06.10 18:06, schrieb Bytecode:
>>>> > Is there a way to make the following code work, apart from placing the
>>>> > "#out" component inside the h:form element?
>>>> >
>>>> > |<?xml version="1.0" encoding="ISO-8859-1" ?>
>>>> > <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 10 Transitional//EN"
>>>> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt
>>>> <http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt>;
>>>> > <html xmlns="http://www.w3.org/1999/xhtml";
>>>> > xmlns:h="http://java.sun.com/jsf/html";
>>>> > xmlns:f="http://java.sun.com/jsf/core"&gt
>>>> <http://java.sun.com/jsf/core"&gt>;
>>>> > <h:head>
>>>> > <title>Welcome</title>
>>>> > </h:head>
>>>> >
>>>> > <h:body>
>>>> >
>>>> > <h:form id="form1">
>>>> >
>>>> > <p><h:outputText id="out" value="#{user.greeting}" /></p>
>>>> >
>>>> > <h:inputText value="#{user.name}" id="user-name" />
>>>> > <p><h:inputSecret value="#{user.password}" id="password" /></p>
>>>> > <p>
>>>> > <h:commandButton value="Login" id="login-button">
>>>> > <f:ajax execute="user-name password" render="out" />
>>>> > </h:commandButton>
>>>> > </p>
>>>> > </h:form>
>>>> > </h:body>
>>>> >
>>>> > </html>
>>>> > |
>>>> >
>>>> >
>>>> >
>>>> > At the moment the following exception is thrown by JSF when rendering
>>>> > the page:
>>>> >
>>>> > |<f:ajax> contains an unknown id'out' - cannot locate it in the
>>>> context of the component login-button|
>>>>
>>>>
>>
>>
>
>

Reply via email to