You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by tapestry newbie <ya...@yahoo.ca> on 2010/07/12 21:23:19 UTC

retrieve textfield value prior to validate/submit

Hi,

I am a Tapestry newbie, using 5.1.   

I have two textfields, the second textfield's potential values is dependent
on the value of the first.  How do I get the value of the first textfield? 
After a validate/submit, there is no problem retrieving this value, but I
need the content of the first textfield before a validate/submit.

Any help/hints appreciated!




-- 
View this message in context: http://old.nabble.com/retrieve-textfield-value-prior-to-validate-submit-tp29140392p29140392.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: retrieve textfield value prior to validate/submit

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 12 Jul 2010 17:09:00 -0300, Pablo dos Reis  
<pa...@gmail.com> wrote:

> Hi,

Hi, guys!

Nice example, Pablo! A StreamResponse is a good choice when all you need  
to return is a String. When you need something more structured, you can  
return a JSSONObject or an JSONArray.


> @Property
> private String url;
>
> /**
> * Register the action Link
> */
> void preRender() {
>
>   Link link = recursosComponente.createActionLink("firstTextField",
> false, new Object[0]);
>   url = link.toAbsoluteURI();
>
> }

I would use a single method for it:

@Inject
private ComponentResources resources;

Link getFirstTextFieldLink() {
	return resources.createEventLink("firstTextField");
}


> /*
> * Action Link Event
> */
>
> StreamResponse onFirsTextField() {
>
>  String value = request.getParameter("firstValue");
>
>  // do some thing
>
>  //return a stream response
>
> }

You can return a JSONObject or JSONArray here too.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: retrieve textfield value prior to validate/submit

Posted by Pablo dos Reis <pa...@gmail.com>.
Hi,

you can use Ajax.Request of Prototype for it.



Create a Action Link for register the method and call this method by Ajax.


Example:


////////////////////////////////////////////////////////////Page
Class///////////////////////////////////////////////////////////////////////////////
@Property
private String url;

/**
* Register the action Link
*/
void preRender() {

  Link link = recursosComponente.createActionLink("firstTextField",
false, new Object[0]);
  url = link.toAbsoluteURI();

}


/*
* Action Link Event
*/

StreamResponse onFirsTextField() {

 String value = request.getParameter("firstValue");

 // do some thing

 //return a stream response

}


///////////////////////////////////////////////////////TEMPLATE//////////////////////////////////////////////////


<input t:type="TextField" id="first" onBlur="callAjax()"/>
<input t:type="TextField" id="second"/>

<script>

   function callAjax() {
      var parameter = 'firstValue=' + $('first').value;

      new Ajax.Request('${url}',parameters: parameter,  {
        onSuccess: function(transport) {

         // transport has a Stream response returned
         // do some thing
        }
   });

</script>



2010/7/12 tapestry newbie <ya...@yahoo.ca>

>
> Hi,
>
> I am a Tapestry newbie, using 5.1.
>
> I have two textfields, the second textfield's potential values is dependent
> on the value of the first.  How do I get the value of the first textfield?
> After a validate/submit, there is no problem retrieving this value, but I
> need the content of the first textfield before a validate/submit.
>
> Any help/hints appreciated!
>
>
>
>
> --
> View this message in context:
> http://old.nabble.com/retrieve-textfield-value-prior-to-validate-submit-tp29140392p29140392.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Pablo Henrique dos Reis