Re: Browser automatically scrolls to contact form in footer (undesirable)

2021-10-27 Thread Cezary Biernacki
Hi,
Tapestry automatically puts focus on the first field of a form. You can
switch off this behaviour by setting the "autofocus" property on the form
to false.

See
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Form.html

Cezary


On Wed, Oct 27, 2021 at 9:37 AM Christopher Dodunski (Tapestry) <
chrisfromtapes...@christopher.net.nz> wrote:

> Hi all,
>
> I've built a new home page for an existing site, and this includes a
> simple contact form in the footer.  When the page loads the browser
> automatically scrolls down to this form, with cursor in the first field.
>   This obviously isn't desirable.
>
> Plain HTML forms don't normally invoke this behaviour, which has me
> thinking that some JavaScript may be involved.  Either on the part of
> Tapestry, or Bootstrap which it employs.
>
> If blocking forms from grabbing focus is possible with a simple CSS
> directive then I've not found it.  What would be the simplest or
> cleanest solution to this potentially common problem?
>
> Thanking you in advance for any suggestions.
>
> Chris.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: upgrade from 3.0.1

2021-07-26 Thread Cezary Biernacki
Hi,
There is no point upgrading to Tapestry 4.x. Unfortunately Tapestry 3 is
quite different from Tapestry 4.x, which is quite different from Tapestry
5.x. Differences are so significant, that you should consider this to be
more of a total rewrite in a new framework, rather than upgrades. At this
point it might be worth evaluating if Tapestry 5 is the right framework for
your project.

If you decide to go ahead with Tapestry 5, I think there is little reason
to try any versions older than 5.7 (and certainly no reason older than
5.6).

Best regards,
Cezary



On Mon, Jul 26, 2021 at 8:00 PM Chris Kujawa  wrote:

> Hello!
>
> I recently started working for a company and am looking into what it will
> take to upgrade our web application from Tapestry version 3.0.1 to
> something a bit more...modern. I've read a bunch of the upgrade docs (both
> older and new) and am wondering...are we better off if we do an
> intermediate upgrade to 4.0.x first, then move to 5, or should we just go
> straight to 5.x?
>
> IF we go to 5.x, is there any reason to start at 5.1...or should we just go
> straight to 5.7? I realize that there's a bunch of 3rd party libraries you
> don't know about, but I can handle determining what the need is there. I
> just get the feeling that the stop at 4.0.x is a moot point, and that we've
> got our work cut out for us.
>
> Thank you in advance for your help!
>
> -Chris
>


Re: The checkbox is checked by default!!

2020-10-06 Thread Cezary Biernacki
Hi,

Tapestry's t:checkbox parameter uses the "value" parameter to determine if
the checkbox should be rendered as checked or not. the "value" parameter
supposed to be a boolean, but if you provide anything else, Tapestry will
attempt to coerce the provided argument to boolean.  There are multiple
built-in Tapestry coercions from various Java types to boolean, some
examples:

   - String - if it is empty or null or equal to "false" (case insensitive)
   is coerced false, otherwise true.
   - Numbers (int, long, etc.) - non-zero values are true;
   - Collections (lists, maps) - non-empty are true;
   - Any other generic object, not coerced otherwise - non-null values are
   true;

So, in your case, "acronyms" is something that Tapestry coerces to Boolean
as the "true" value. If you need to make the checkbox unchecked, provide
the "value" parameter that evaluates as "false".

About coercions you can read here:
https://tapestry.apache.org/parameter-type-coercion.html
https://tapestry.apache.org/type-coercion.html

Details about default type coercions can be found here:
https://github.com/apache/tapestry-5/blob/master/commons/src/main/java/org/apache/tapestry5/ioc/internal/BasicTypeCoercions.java

Cezary


On Tue, Oct 6, 2020 at 9:33 PM marwa hussein 
wrote:

> On Tue, Oct 6, 2020 at 5:17 PM Nathan Quirynen <
> nat...@pensionarchitects.be>
> wrote:
>
> > Is it possible that your "acronyms" property has a value of true when
> > rendering ?
> >
> > No it is not. Also I am wondering what could make the "checked" attribute
> default to be true!!
> Also I cant find in tapestry API how to change the attribute checked value
> to false!!
>
>
> >
> > Op 6/10/2020 om 14:42 schreef marwa hussein:
> > > Hi all,
> > >
> > > I am trying to populate a grid with some values and add a column with a
> > > checkbox to select a value..
> > >
> > > 
> > >
> > >
> > >  
> > >
> > > The problem when the grid is populated I found the Checkbox checked by
> > > default, although I didn't use the "check" attribute (which suppose to
> be
> > > "false" by default)!!
> > > how can I make solve this and make it unchecked in the begining??
> > >
> > > Regards,
> > > Marwa
> > >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>
> --
>
>
>
> *Marwa Hussein M. TA @ Information Systems Department Faculty of Computers
> & Information Assuit University*
> 
>


Re: Dissapearing attribute from session

2020-05-11 Thread Cezary Biernacki
Hi,
Usually such symptoms appear when your production system has multiple
instances with a load balancer but without the "sticky sessions" option
enabled. The load balancer sends request from one user to multiple
instances, so it looks like attributes from the session disappear, while in
reality they were set on a different instances. This problem is unrelated
to Tapestry itself.

If your configuration matches above, either reconfigure your load balancer
to send request from one user to the same instance, or save/restore
sessions on every request from some external database.

Best regards,
Cezary



On Mon, 11 May 2020, 16:30 Michał Więckowski, 
wrote:

> Hello everyone,
>
> I'm expecting bizarre behavior and  I'm slowly running out of options
> what can be wrong. Maybe someone had a similar problem.
>
> I've got a tapestry app (T5.5) and sometimes when I refresh pages (this
> behavior I can see in many pages across my app), my session attributes are
> lost. By "lost" I mean they are set as null, as they were never set. To be
> more precise, I can observe this in a Map object that is stored in the
> session.
> I've observed that this loss is happening during a full page reload (in
> other words, running ajax "hits" don't cause it).
> What's more, this lost I can only see in my prod env (which in this case is
> Azure). In my local development env, everything is working like a charm.
>
> I know that this is only a brief description, but I don't even know what
> details may be helpful with the solution to this problem.  Please ask and
> thanks in advance.
>
>
> --
> regards,
>
> MW
>


Re: Modules into Tapestry 5.5.0

2020-04-14 Thread Cezary Biernacki
Hi Carlos,
Tapestry in the production mode minifies all JavaScript. It seems that
minification in T5.5 adds "'use strict';" pragma to minified files. "'use
strict';" instructs the browser to fail if anything is wrong with your
code, instead of trying quietly to fix problems. In your code "init =
*function*(){"  refers to undeclared variable "init". Non-strict JavaScript
automatically defines such variable, but in the strict mode it fails with
the error: "init is not defined". All you need is to declare "init",
e.g.: "var init = function(){".

"use strict" is generally a good idea, because it ensures that all browser
will execute your code in the same way, and any typos will not be silently
ignored. I recommend adding line
'use strict';
at the beginning of your .js file, so the code will work the same way in
the development and and the production mode.

Best regards,
Cezary




On Mon, Apr 13, 2020 at 8:45 PM Carlos Montero Canabal <
carlosmonterocana...@gmail.com> wrote:

> Hi Tapestry users!
>
> I'm deploying my first 5.5.0 app into production... and I checked that my
> modules js doesnt work with production mode = true.
>
> Example:
>
> article.js:
>
> define(["jquery", "prism"], *function*($, Prism) {
>
> init = *function*(){
>
> Prism && Prism.hasOwnProperty('default') ? Prism['default'] : Prism;
>
> }
>
> *return*{
>
> init : init
>
> }
>
> });
>
>
> ArticlePage.java
>
>
> javaScriptSupport.require("article").invoke("init");
>
>
> NOTE: It works fine with production mode = false.
>
>
> The error is "RequireJS error: define: init is not defined, modules
> article".
>
>
> However, if I rewrite my module as below:
>
>
> define(["jquery", "prism"], *function*($, Prism) {
>
> *return* *function*(){
>
> Prism && Prism.hasOwnProperty('default') ? Prism['default'] : Prism;
>
> }
>
> });
>
>
> And my javacode to:
>
>
> javaScriptSupport.require("article");
>
>
> It works fine. But I want to define multiple functions inside the same
> module.
>
>
> In my apps in Tapestry 5.4.X I always use the modules as I wrote before.
>
>
> Any suggestion?
>
>
> For other hand, I think there is a missaligment on tapestry-webresources:
>
>
> [image: image.png]
>
> In my project, with maven 3.6.3 protobuf-java is 2.5.0 from less4j but
> webapp breaks when it inits the closure compiler. I had to fix writing the
> version in my pom to 3.0.2.
>
> Best regards
>
> Carlos Montero
>


Re: Re: T5.5.0-beta-3: document.observe is not a function

2020-02-14 Thread Cezary Biernacki
I am glad to help.

As I wrote, I didn't test codes, so there are some bugs in them. In case
somebody having a similar problem, there is an errata:

In Step 1, missing a line at the end of code block, like this:

})();


In Step 3. instead of "display-content.js" it should be without ".js",
javaScriptSupport.require("display-content");


Best regards,
Cezary

On Fri, Feb 14, 2020 at 10:19 AM Lothar Nieswandt 
wrote:

> Hi Cezary,
>
> thanks a lot for the quick reply. I didn't get the first solution to work,
> but never mind. Avoiding prototype in the first place (your offered second
> solution) did the trick, so thanks a lot.
>
> Lothar
>
>
> Gesendet: Mittwoch, 12. Februar 2020 um 19:13 Uhr
> Von: "Cezary Biernacki" 
> An: "Tapestry users" 
> Betreff: Re: T5.5.0-beta-3: document.observe is not a function
> Hi,
> I don't use T5.5, but probably your code would fail in T5.4 as well.
> Tapestry puts JavaScript loading at the end of , as it is a general
> best practice for improving page loading times.
>
> I would change this in the following way:
>
> ---
> 1. Move JS code to a separate file that works as a module. Put following
> code in META-INF/modules/display-content.js in your resources folder
> (normally src/main/resources)
>
> (function() {
> define(["t5/core/dom"], function() {
>
> document.observe("dom:loaded", function() {
>
> $("content").style.display = 'block';
>
> });
>
> }
> )
>
>
> 2. Remove the offending block "  ... " from your ".tml"
> file
>
> 3. In Java class that it is related to the .tml file from step 2, add
> inclusion of display-content.js
>
> @Inject
> private JavaScriptSupport javaScriptSupport;
>
> @BeginRender
> void addDisplayContent(final MarkupWriter writer) {
> javaScriptSupport.require("display-content.js");
> }
>
> ---
>
> As far as I can tell, these changes should work in Tapestry 5.4 and
> Tapestry 5.5. An alternative approach, is to rewrite JavaScript code in
> .tml to use plain DOM, instead of any external library, like:
> <script type="text/javascript">
> document.addEventListener('DOMContentLoaded',
> function() {
> document.getElementById('content').style.display = 'block';
> }
> , false);
> 
>
>
> Best regards,
> Cezary
>
> PS. I have not tested any code above, so you might need to fix any typos,
> missing commas, etc.
>
>
> On Wed, Feb 12, 2020 at 5:37 PM Lothar Nieswandt 
> wrote:
>
> > Hello T5-team,
> >
> > I am currently in the process of porting a T5.3 application to T5.5-beta
> > (expecting the latter to become final soon). Altough the application is
> > rather simple and does not provider any client side customizations, I do
> > get into trouble with some JS-related stuff.
> >
> > The application's index page does not get loaded, the browser console
> > complains:
> >
> > "(index):7 Uncaught TypeError: document.observe is not a function"
> >
> > This obviously relates to the following piece of source code:
> >
> >  > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;> > data-debug-enabled="true" data-locale="de" xmlns="
> > http://www.w3.org/1999/xhtml[http://www.w3.org/1999/xhtml];>
> > 
> >  > name="generator"/> > http-equiv="content-type"/>
> >  > type="image/x-icon" rel="shortcut icon"/>
> > Title
> > 
> > ==> document.observe("dom:loaded", function() {
> > $("content").style.display = 'block';
> > });
> > 
> >
> >
> > After some research I found out that the relevant call belongs to
> > prototype.js which should still be supported in T5.5, shouldn't it?
> >
> > As I further found out, the include of prototype.js is still present in
> > the page, but has been moved to the  part of the page as opposed to
> > the  part where it was placed in T5.3.
> >
> > As I stated in earlier, we do not rely on any properietory JS extensions,
> > so I would happily replace the Prototype dependency. I just don't know
> how.
> >
> > Any help appreciated.
> >
> > Lothar
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: T5.5.0-beta-3: document.observe is not a function

2020-02-12 Thread Cezary Biernacki
Hi,
I don't use T5.5, but probably your code would fail in T5.4 as well.
Tapestry puts JavaScript loading at the end of , as it is a general
best practice for improving page loading times.

I would change this in the following way:

---
1. Move JS code to a separate file that works as a module. Put following
code in META-INF/modules/display-content.js in your resources folder
(normally src/main/resources)

(function() {
define(["t5/core/dom"], function() {

document.observe("dom:loaded", function() {

$("content").style.display = 'block';

});

}
)


2. Remove the offending block "  ... " from your ".tml"
file

3. In Java class that it is related to the .tml file from step 2, add
inclusion of display-content.js

@Inject
private JavaScriptSupport javaScriptSupport;

@BeginRender
void addDisplayContent(final MarkupWriter writer) {
javaScriptSupport.require("display-content.js");
 }

---

As far as I can tell, these changes should work in Tapestry 5.4 and
Tapestry 5.5. An alternative approach, is to rewrite JavaScript code in
.tml to use plain DOM, instead of any external library, like: