How can we fill a html text area on pharo

139 Views Asked by At

For a login through pharo using the html form there is a method of Znclient which is formAt:add: followed by a post. So I was wondering how to I fill a textArea of html form and make post. Is there a method for such action?

<div><textarea id="technique" name="technique" class="technique">jumping</textarea></div><label>Résultats :</label>
<div><textarea id="resultat" name="resultat" class="resultat">Higher score</textarea></div><label>Conclusion :</label>
<div><textarea id="conclusion" name="conclusion" class="conclusion">Best jumper of the school</textarea></div>

1

There are 1 best solutions below

4
On

Looking into ZnClient class in the System Browser you can see the comments for following methods:

formAt:add: - "Add key equals value to the application/x-www-form-urlencoded entity of the current request. This is for multi-values form fields."

formAt:put: - "Set key equal to value in the application/x-www-form-urlencoded entity of the current request."

formAdd: - "Add the key->value association to the application/x-www-form-urlencoded entity of the current request."

formAddAll: - "Add all key->value associations of keyedCollection to the application/x-www-form-urlencoded entity of the current request."

We haven't used formAt:add: in any of our previous q&a on this and we should avoid it here. Use one of the last 3 methods:

| client |
client := ZnClient new url: 'http://server/some-script.cgi'.

then...

client formAt: 'technique'  put: 'foo'; 
       formAt: 'resultat'   put: 'bar'; 
       formAt: 'conclusion' put: 'baz'; 
       post.

or...

client formAdd: 'technique'  -> 'foo'; 
       formAdd: 'resultat'   -> 'bar'; 
       formAdd: 'conclusion' -> 'baz'; 
       post.

or this...

client formAddAll: {
    'technique'  -> 'foo'. 
    'resultat'   -> 'bar'. 
    'conclusion' -> 'baz'.
} asDictionary; post.