You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Gilberto <gi...@gmail.com> on 2010/11/18 21:18:56 UTC

[PageLink | ActionLink] are not localized

Hi,

class: ViewLegalEntity.java[1]

<quote>
    protected PageLink editLink = new PageLink("editLink",
EditLegalEntity.class);
    protected ActionLink deleteLink = new ActionLink("deleteLink", this,
"onDeleteClick");
</quote>

properties:ViewLegalEntity.properties[1]

<quote>
editLink.label=Edit
editLink.title=Edit LegalEntity record
deleteLink.label=Delete
deleteLink.title=Delete LegalEntity record
</quote>

That doesn't work! Are those definition correct?

Other question: can I localize the ActionLink's attribute?
Like so:
<quote>
deleteLink.attribute.onclick=return window.confirm('Are you sure you want to
delete this record?');
</quote>
This one not work.

Regards,

Gilberto

[1]
http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/java/park/web/page/ViewLegalEntity.java
[2]
http://code.google.com/p/construtor/source/browse/trunk/cip/park/src/main/java/park/web/page/ViewLegalEntity.properties

Re: [PageLink | ActionLink] are not localized

Posted by Gilberto <gi...@gmail.com>.
2010/11/19 Bob Schellink <sa...@gmail.com>

> On 20/11/2010 03:10, Gilberto wrote:
> >
> >
> > 2010/11/19 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>
>
> >     > <quote>
> >     >     protected PageLink editLink = new PageLink("editLink",
> EditLegalEntity.class);
> >     >     protected ActionLink deleteLink = new ActionLink("deleteLink",
> this, "onDeleteClick");
> >     > </quote>
>
> On second glance, the links aren't added to the Page as is done with form
> and table. In other words
> the links do not have a parent, and thus cannot navigate up to the Page to
> pull in the page
> localizations. I'm pretty sure the onDeleteClick doesn't work either
> because of this.
>
> You are right again! The correct way:
<quote>
        addControl(form);
        addControl(table);
        addControl(deleteLink);
        addControl(editLink);
</quote>


> Note: the Click examples makes use of @Bindable annotation which adds the
> control to the page.
> However I recommend not using it on controls as people generally find it
> difficult to understand and
> maintain.
>
> > PS.: Do you know why the menu items are been duplicate? (see the link)
>
>
> Strange. Can you use your debugger to step into menuFactory.getRootMenu?

Yes [1], it appears ok.


> Either the menus are loaded
> twice or the menus are rendered twice. What happens if you use the macro
> #writeMenu($rootMenu) to
> render? Are there still dups?
>
> Yes, they continues duplicated.
But I've found the problem. I've put fake image paths on imageSrc tag(I
don't have the images yet!), for example:
<quote>
  <menu label=" Parking" path="#" imageSrc="/assets/images/controls.png">
</quote>
That caused the rendering problem. After removing that tag the menu works
perfectly (either with or without the macro).

Regards,

Gilberto

[1]http://dl.dropbox.com/u/9093640/getRootMenu.png

Re: [PageLink | ActionLink] are not localized

Posted by Bob Schellink <sa...@gmail.com>.
On 20/11/2010 03:10, Gilberto wrote:
> 
> 
> 2010/11/19 Bob Schellink <sabob1@gmail.com <ma...@gmail.com>>

>     > <quote>
>     >     protected PageLink editLink = new PageLink("editLink", EditLegalEntity.class);
>     >     protected ActionLink deleteLink = new ActionLink("deleteLink", this, "onDeleteClick");
>     > </quote>

On second glance, the links aren't added to the Page as is done with form and table. In other words
the links do not have a parent, and thus cannot navigate up to the Page to pull in the page
localizations. I'm pretty sure the onDeleteClick doesn't work either because of this.

Note: the Click examples makes use of @Bindable annotation which adds the control to the page.
However I recommend not using it on controls as people generally find it difficult to understand and
maintain.

> PS.: Do you know why the menu items are been duplicate? (see the link)


Strange. Can you use your debugger to step into menuFactory.getRootMenu? Either the menus are loaded
twice or the menus are rendered twice. What happens if you use the macro #writeMenu($rootMenu) to
render? Are there still dups?

Bob

Re: [PageLink | ActionLink] are not localized

Posted by Gilberto <gi...@gmail.com>.
2010/11/19 Bob Schellink <sa...@gmail.com>

> Hi,
>
> On 19/11/2010 07:18, Gilberto wrote:
> > class: ViewLegalEntity.java[1]
> >
> > <quote>
> >     protected PageLink editLink = new PageLink("editLink",
> EditLegalEntity.class);
> >     protected ActionLink deleteLink = new ActionLink("deleteLink", this,
> "onDeleteClick");
> > </quote>
> >
> > properties:ViewLegalEntity.properties[1]
> >
> > <quote>
> > editLink.label=Edit
> > editLink.title=Edit LegalEntity record
> > deleteLink.label=Delete
> > deleteLink.title=Delete LegalEntity record
> > </quote>
> >
> > That doesn't work! Are those definition correct?
>
> Your code looks right. Have a look at your war and make sure your property
> files are included next
> to your class files.
>
> Yes, they are:
<quote>
gilberto@SUGEP-DMASI:~/dev/netbeans-config/cip/park$ jar -ft
target/park-1.0-SNAPSHOT.war|grep properties
WEB-INF/classes/park/web/page/MainMenu.properties
WEB-INF/classes/park/web/page/EditLegalEntity.properties
WEB-INF/classes/park/web/page/ViewLegalEntity.properties
WEB-INF/classes/click-page.properties
META-INF/maven/com.google.constructor/park/pom.properties
</quote>

>
> > Other question: can I localize the ActionLink's attribute?
> > Like so:
> > <quote>
> > deleteLink.attribute.onclick=return window.confirm('Are you sure you want
> to delete this record?');
>
>
> Both Page and Controls have getMessage methods and variants for this
> purpose:
>
> String msg = getMessage("deleteMsg");
> deleteLink.attribute.onclick=return window.confirm( msg );
>
> Good, I've did this way:
<quote>
        //deleteLink.setAttribute("onclick", "return window.confirm('Are you
sure you want to delete this record?');");
        deleteLink.setAttribute("onclick",
getMessage("deleteLink.attribute.onclick"));
</quote>

But the Page and Action link doesn't work[1] yet.
Any idea?

Regards,
Gilberto

PS.: Do you know why the menu items are been duplicate? (see the link)


[1]http://dl.dropbox.com/u/9093640/Screenshot.png

Re: [PageLink | ActionLink] are not localized

Posted by Bob Schellink <sa...@gmail.com>.
Hi,

On 19/11/2010 07:18, Gilberto wrote:
> class: ViewLegalEntity.java[1]
> 
> <quote>
>     protected PageLink editLink = new PageLink("editLink", EditLegalEntity.class);
>     protected ActionLink deleteLink = new ActionLink("deleteLink", this, "onDeleteClick");
> </quote>
> 
> properties:ViewLegalEntity.properties[1]
> 
> <quote>
> editLink.label=Edit
> editLink.title=Edit LegalEntity record
> deleteLink.label=Delete
> deleteLink.title=Delete LegalEntity record
> </quote>
> 
> That doesn't work! Are those definition correct?

Your code looks right. Have a look at your war and make sure your property files are included next
to your class files.


> Other question: can I localize the ActionLink's attribute?
> Like so:
> <quote>
> deleteLink.attribute.onclick=return window.confirm('Are you sure you want to delete this record?');


Both Page and Controls have getMessage methods and variants for this purpose:

String msg = getMessage("deleteMsg");
deleteLink.attribute.onclick=return window.confirm( msg );

You can create a custom delete Link if you need to use this behavior in multiple places.

Kind regards

Bob