You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Amit Nair <am...@yahoo.com> on 2007/01/16 18:55:43 UTC
JSF-DWR Components not adding to viewroot
Hi Team
I am trying to integrate the JSF & DWR.
In the jsp page I have got a dataTable which is iterating over a list of
objects, based upon whose values the components are displayed inside
DataTable. The final output of the dataTable is a series of questions
against which there are various type of components which server as answer
for the question. This comes fine.
But now my requirement is if I change certain value of component then it
should trigger a server call & fetch some new questions & their answers. For
this I am using DWR. Through DWR I am able to call a method of managed bean
which return a List of Objects. Based upon the value of objects I am
creating the components [text box, drop down etc] & adding it to the JSP.
The components are coming on the page, but when the form is submitted these
newly added components are not found in the view. On trying to find the
value of component through java script I am getting the value. But since
these newly added components are missing from the view root I am not able to
save the correct data.
Could anyone through some light on this as where I am going wrong or what
should I do to overcome this.
Thanks in Advance
Amit
--
View this message in context: http://www.nabble.com/JSF-DWR-Components-not-adding-to-viewroot-tf3022443.html#a8395311
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF-DWR Components not adding to viewroot
Posted by Amit Nair <am...@yahoo.com>.
Hi
Thanks for your response.
I tried but that didn't went well for me. Anyways now i trying out Ajax4JSF.
This looks like a good thing. I did a POC in this & got the desired result.
But now the problem which I am getting is the h:commandLink which are there
in the pages are not getting fired. They are not calling the backing bean
method. It is giving javascript error.
Does anyone knows as what is the problem???
Regards
Amit
iamnoah wrote:
>
> Amit,
> How are you creating the components? If you just add text boxs, drop
> downs, etc to the view on the client side, JSF doesn't know anything
> about those parameters, so it can't map them to the ViewModel it has.
>
> This is just a hack, but you could:
> 1. add an h:inputHidden component to your form
> 2. When you get the results back from DWR, create the drops downs,
> etc. like you already are, but add some Javascript that either:
> a. listens to the onchange event on each added input
> b. listens for the form submission
> and encodes the values of the extra inputs in the hidden field. e.g.
> something like: "extraInput1=foo&extraInput2=bar"
> 3. Have your submit action parse the value from the hidden field
> (since it was always in your view, you can get its value) and do
> whatever you want with the data.
>
> Like I said, that is just a hack, and you wont be able to use any JSF
> converters, validators, etc. on the extra fields. It should be enough
> for simple cases, but I wouldn't want to do that very often.
>
> Probably JSF 1.2 will have a much better solution, or maybe Sandbox or
> Trinidad already has something that can help.
>
> On 1/16/07, Amit Nair <am...@yahoo.com> wrote:
>>
>> Hi Team
>>
>> I am trying to integrate the JSF & DWR.
>>
>> In the jsp page I have got a dataTable which is iterating over a list of
>> objects, based upon whose values the components are displayed inside
>> DataTable. The final output of the dataTable is a series of questions
>> against which there are various type of components which server as answer
>> for the question. This comes fine.
>>
>> But now my requirement is if I change certain value of component then it
>> should trigger a server call & fetch some new questions & their answers.
>> For
>> this I am using DWR. Through DWR I am able to call a method of managed
>> bean
>> which return a List of Objects. Based upon the value of objects I am
>> creating the components [text box, drop down etc] & adding it to the JSP.
>> The components are coming on the page, but when the form is submitted
>> these
>> newly added components are not found in the view. On trying to find the
>> value of component through java script I am getting the value. But since
>> these newly added components are missing from the view root I am not able
>> to
>> save the correct data.
>>
>> Could anyone through some light on this as where I am going wrong or what
>> should I do to overcome this.
>>
>> Thanks in Advance
>> Amit
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JSF-DWR-Components-not-adding-to-viewroot-tf3022443.html#a8395311
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JSF-DWR-Components-not-adding-to-viewroot-tf3022443.html#a8474811
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF-DWR Components not adding to viewroot
Posted by noah <ia...@gmail.com>.
Amit,
How are you creating the components? If you just add text boxs, drop
downs, etc to the view on the client side, JSF doesn't know anything
about those parameters, so it can't map them to the ViewModel it has.
This is just a hack, but you could:
1. add an h:inputHidden component to your form
2. When you get the results back from DWR, create the drops downs,
etc. like you already are, but add some Javascript that either:
a. listens to the onchange event on each added input
b. listens for the form submission
and encodes the values of the extra inputs in the hidden field. e.g.
something like: "extraInput1=foo&extraInput2=bar"
3. Have your submit action parse the value from the hidden field
(since it was always in your view, you can get its value) and do
whatever you want with the data.
Like I said, that is just a hack, and you wont be able to use any JSF
converters, validators, etc. on the extra fields. It should be enough
for simple cases, but I wouldn't want to do that very often.
Probably JSF 1.2 will have a much better solution, or maybe Sandbox or
Trinidad already has something that can help.
On 1/16/07, Amit Nair <am...@yahoo.com> wrote:
>
> Hi Team
>
> I am trying to integrate the JSF & DWR.
>
> In the jsp page I have got a dataTable which is iterating over a list of
> objects, based upon whose values the components are displayed inside
> DataTable. The final output of the dataTable is a series of questions
> against which there are various type of components which server as answer
> for the question. This comes fine.
>
> But now my requirement is if I change certain value of component then it
> should trigger a server call & fetch some new questions & their answers. For
> this I am using DWR. Through DWR I am able to call a method of managed bean
> which return a List of Objects. Based upon the value of objects I am
> creating the components [text box, drop down etc] & adding it to the JSP.
> The components are coming on the page, but when the form is submitted these
> newly added components are not found in the view. On trying to find the
> value of component through java script I am getting the value. But since
> these newly added components are missing from the view root I am not able to
> save the correct data.
>
> Could anyone through some light on this as where I am going wrong or what
> should I do to overcome this.
>
> Thanks in Advance
> Amit
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/JSF-DWR-Components-not-adding-to-viewroot-tf3022443.html#a8395311
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>