[TRINIDAD] Javascript sendPartialFormPost - how to read param in bean

View: New views
3 Messages — Rating Filter:   Alert me  

[TRINIDAD] Javascript sendPartialFormPost - how to read param in bean

by Elmar Kretzer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,

when i am triggering a partial submit via javascript and add e.g. param1 to the call,
how can i read the value of the param in the bean from the FacesContext ?

Javascript Code: 
TrPage.getInstance().sendPartialFormPost(
     theForm,
     {param1: "value1", param2: "value2"}); 


any clues?

Thanks in advance
Elmar

Re: [TRINIDAD] Javascript sendPartialFormPost - how to read param in bean

by Cédric Durmont :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't know the answer either (and I'd be glad to know it, btw), but
what I do is that my javascript code updates form fields (hidden if
necessary) with values I want to send back :

in jspx :
...
function myfunc()
{
  document.getElementById("param1").value=someValue;
  TrPage.getInstance().sendPartialFormPost(myForm,
                                             {source: "myButton"},
                                             {});
}

...
<tr:inputText type="hidden" id="param1" value="#{myBean.param1}"/>
<tr:commandButton action="#{myBean.doSomething}" id="myButton">

in bean :
public String doSomething()
{
  String s=getParam1();
  ...
}

Note that :
-you can hide the button as well (with inlineStyle)
-everything will work as is you clicked the button. So you can use
partialTriggers, partialSubmit, etc. referencing the button, je
javascript code will do the same.
-I think the Trinidad documentation should have a similar example. I
spent hours figuring out that "source" thing !

Regards,
Cedric


2009/10/7 Elmar Kretzer <e.kretzer@...>:

> Hi everyone,
>
> when i am triggering a partial submit via javascript and add e.g. param1 to
> the call,
>
> how can i read the value of the param in the bean from the FacesContext ?
>
> Javascript Code:
>
> TrPage.getInstance().sendPartialFormPost(
>      theForm,
>      {param1: "value1", param2: "value2"});
>
> any clues?
>
> Thanks in advance
>
> Elmar

Re: [TRINIDAD] Javascript sendPartialFormPost - how to read param in bean

by Elmar Kretzer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your response Cédric,

that seems to be a clean approach.
Furthermore this way it should also be possible to to avoid writing
> TrPage.getInstance().sendPartialFormPost(myForm,
>     {source: "myButton"},
>     {});

and instead make use of e.g. jQuery(''#mybutton).trigger("click").




But does anyone know if it is possible to read those PartialFormPost  
Params?

>> TrPage.getInstance().sendPartialFormPost(
>>     theForm,
>>     {param1: "value1", param2: "value2"});

Maybe from the RequestContext ?

Regards, Elmar





Am 07.10.2009 um 12:39 schrieb Cédric Durmont:

> I don't know the answer either (and I'd be glad to know it, btw), but
> what I do is that my javascript code updates form fields (hidden if
> necessary) with values I want to send back :
>
> in jspx :
> ...
> function myfunc()
> {
>  document.getElementById("param1").value=someValue;
>  TrPage.getInstance().sendPartialFormPost(myForm,
>     {source: "myButton"},
>     {});
> }
>
> ...
> <tr:inputText type="hidden" id="param1" value="#{myBean.param1}"/>
> <tr:commandButton action="#{myBean.doSomething}" id="myButton">
>
> in bean :
> public String doSomething()
> {
>  String s=getParam1();
>  ...
> }
>
> Note that :
> -you can hide the button as well (with inlineStyle)
> -everything will work as is you clicked the button. So you can use
> partialTriggers, partialSubmit, etc. referencing the button, je
> javascript code will do the same.
> -I think the Trinidad documentation should have a similar example. I
> spent hours figuring out that "source" thing !
>
> Regards,
> Cedric
>
>
> 2009/10/7 Elmar Kretzer <e.kretzer@...>:
>> Hi everyone,
>>
>> when i am triggering a partial submit via javascript and add e.g.  
>> param1 to
>> the call,
>>
>> how can i read the value of the param in the bean from the  
>> FacesContext ?
>>
>> Javascript Code:
>>
>> TrPage.getInstance().sendPartialFormPost(
>>     theForm,
>>     {param1: "value1", param2: "value2"});
>>
>> any clues?
>>
>> Thanks in advance
>>
>> Elmar
>