You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by dinesh707 <di...@gmail.com> on 2012/10/25 08:53:02 UTC

Why variable do not update in a text field

following are my code parts. So when some one and a mp3URL to some text area,
system will send a ajax request to " onMp3UrlChanged()". Then it will get
the title and set that value into "songName" and refresh the zone. IT
WORKS!. But my problem is later when i change the text in the TextField and
call "uploadToDB()" inside "onSuccess()", then still the output will be last
set value to the "songName". It is not taking the new update from the form. 

WHY? and how to fix it ? 

--- java class ---
@Persist 
@Property
private String songName;

@InjectComponent(value="songName")
private TextField songNameField;

//this is an ajax call
void onMp3UrlChanged() {
mp3Url = request.getParameter("param");
sip = new SongInformationParser(mp3Url);
songName = sip.getTitle();
disabled = false;
ajaxResponseRenderer.addRender("songInfoZone1", songInfoZone1)
}

void uploadToDB(){
System.out.println(songName);
}

--- TML ---
<t:zone t:id="songInfoZone1" id="songInfoZone1">			
<input t:type="TextField" t:id="songName" disabled="${disabled}" size="30"/>
</t:zone>







--
View this message in context: http://tapestry.1045711.n5.nabble.com/Why-variable-do-not-update-in-a-text-field-tp5717217.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: Why variable do not update in a text field

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 25 Oct 2012 04:53:02 -0200, dinesh707 <di...@gmail.com> wrote:

> <t:zone t:id="songInfoZone1" id="songInfoZone1">			
> <input t:type="TextField" t:id="songName" disabled="${disabled}"  
> size="30"/>
> </t:zone>

I'm not sure if that's the source of your problem, but your template above  
does have an error: it uses a ${} expansion for passing a parameter. Never  
do that. It's always wrong or useless. In your template above, disabled,  
which I guess is a boolean parameter, is first converted to a String  
because it is inside a ${} expansion. The disabled parameter of TextField  
is a boolean, so Tapestry will need to convert the String to a Boolean. I  
don't think Tapestry has an specific coercion from String to Boolean. If  
not, it will use the generic Object to Boolean one, which returns true of  
the object isn't null and false otherwise. The ${} expansion always  
converts the value to String, so ${disabled} will always be converted to  
true.

Short answer: use disabled="disabled". Use ${} just for outputting stuff  
into HTML.

-- 
Thiago H. de Paula Figueiredo

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


Re: Why variable do not update in a text field

Posted by derkoe <ta...@gmail.com>.
dinesh707 wrote
> following are my code parts. So when some one and a mp3URL to some text
> area, system will send a ajax request to " onMp3UrlChanged()". Then it
> will get the title and set that value into "songName" and refresh the
> zone. IT WORKS!. But my problem is later when i change the text in the
> TextField and call "uploadToDB()" inside "onSuccess()", then still the
> output will be last set value to the "songName". It is not taking the new
> update from the form. 
> 
> WHY? and how to fix it ? 
> 
> --- java class ---
> @Persist 
> @Property
> private String songName;
> 
> @InjectComponent(value="songName")
> private TextField songNameField;
> 
> //this is an ajax call
> void onMp3UrlChanged() {
> mp3Url = request.getParameter("param");
> sip = new SongInformationParser(mp3Url);
> songName = sip.getTitle();
> disabled = false;
> ajaxResponseRenderer.addRender("songInfoZone1", songInfoZone1)
> }
> 
> void uploadToDB(){
> System.out.println(songName);
> }
> 
> --- TML ---
> <t:zone t:id="songInfoZone1" id="songInfoZone1">
> 			
> <input t:type="TextField" t:id="songName" disabled="${disabled}"
> size="30"/>
> </t:zone>

Is your disabled property also @Persist? If not it will be re-initalized
with false and Tapestry will not bind disabled fields.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Why-variable-do-not-update-in-a-text-field-tp5717217p5717223.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