[Seaside] Achor validation

Johan Brichau johan at inceptive.be
Tue Apr 30 19:06:53 UTC 2019


Maarten,

What do you mean with ‘validation’ ? What do you want to validate?

The download attribute only tells the browser to download the url contents rather than open it in the browser [1]

If you want to produce the contents of the file from within Seaside, you will need to control the response in the callback, rather than execute an ‘action’.
The return value of an action callback is never what Seaside answers to the browser. This is what you seem to expect in your code snippet.

You need something like:
	callback:[ self requestContext respond: [:response | self writeYourFileOnTheResponse: response ] ]
You can also check it here: http://book.seaside.st/book/fundamentals/forms/fileupload <http://book.seaside.st/book/fundamentals/forms/fileupload>

Mind that #callback: sets (and overwrites) the href attribute on the anchor.
That means the first statement that sets the href manually does not have any effect (and is, in fact, not correct).
If you want to put a href manually, use #url: 

Hope this helps
Johan

[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes>

> On 30 Apr 2019, at 18:24, Maarten Mostert <maarten.mostert at wanadoo.fr> wrote:
> 
> Hello,
> 
> Is there something inside that allows me to trigger a smalltalk action as a validation before anything else.
> 
> I do something like this:
> 
> (html anchor)
> 							attributeAt: 'href' put: ’Somefile' ;
> 							class: 'pure-button pure-button-primary';
> 							attributeAt: 'download' put:  ’some download file';
> 							callback: [self  getInventoryFile];
> 							with: 
> 									[(html tag: 'i')
> 										class: 'fas fa-download';
> 										style: 'font-size: 14px;'.
> 									html space.
> 									html space.
> 									html text: 'Download counter’]
> 
> The callback is not executed now as the anchor directly responds to the download attribute.
> 
> Thanks in advance.
> 
> Maarten
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20190430/130a6e82/attachment.html>


More information about the seaside mailing list