1

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>
eMBee
  • 793
  • 6
  • 16
ludo
  • 543
  • 3
  • 14

1 Answers1

3

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.
draegtun
  • 22,441
  • 5
  • 48
  • 71
  • This seems not to work for the textarea form. Is there a way perhaps to remplace the value contained in the textarea? – ludo Jan 11 '18 at 06:35
  • @ludo - Http POSTing just sends form name & data pairs (key/value) and so doesn't care if its a ` – draegtun Jan 11 '18 at 17:01
  • Yes you are right It works. My problem was that I was missing another text area different from the listed above. Thanks @draegtun – ludo Jan 12 '18 at 06:45
  • @ludo - You're welcome, glad you have now resolved it. – draegtun Jan 12 '18 at 10:55