You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Tauren Mills (JIRA)" <ji...@apache.org> on 2007/09/27 07:17:50 UTC

[jira] Created: (WICKET-1016) ExternalLink doesn't use model

ExternalLink doesn't use model
------------------------------

                 Key: WICKET-1016
                 URL: https://issues.apache.org/jira/browse/WICKET-1016
             Project: Wicket
          Issue Type: Bug
          Components: wicket
            Reporter: Tauren Mills
            Priority: Minor


I don't understand why ExternalLink doesn't store the external href as
the model.  It stores it in an href property.  It seems to not follow
the normal wicket way.

This makes it difficult to do things like display a link only if the
model is not null.  For instance:

add(new ExternalLink("web", new PropertyModel(service,"web")) {
       @Override
       public boolean isVisible() {
               return getModelObject() != null;
       }
});

The problem is that getModelObject() is always null, because the
PropertyModel is stored in the href property.  And since isVisible()
is part of Component, the href property isn't accessible.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1016) ExternalLink doesn't use model

Posted by "Tauren Mills (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530882 ] 

Tauren Mills commented on WICKET-1016:
--------------------------------------

Martin,

That patch works for me!  However, eclipse complained of an error (not a warning) in ExternalLinkPage_2.java:

The serializable class  does not declare a static final serialVersionUID field of type long	wicket/src/test/java/org/apache/wicket/markup/html/link	ExternalLinkPage_2.java	line 31	

Once I added serialVersionUID to the anonymous class, the error went away:

	public ExternalLinkPage_2()
	{
		add(new ExternalLink("myLink", new Model(null))
		{
			private static final long serialVersionUID = 1L;

			public boolean isVisible()
			{
				return getModelObject() != null;
			}
		});
	}

I thought this was strange because I normally get warnings about serialVersionUID, but in this case it was an error.

BTW, there was some discussion on the mailing list about ExternalLink models:
http://www.nabble.com/text-in-Link-vs-ExternalLink-tf939840.html#a2435084

I look forward to you committing this to trunk.

Thanks again!
Tauren



> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Priority: Minor
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1016) ExternalLink doesn't use model

Posted by "Martin Funk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531383 ] 

Martin Funk commented on WICKET-1016:
-------------------------------------

Coming up with something else.

Your needs can be achieved like this:

public class ExternalLinkPage_1 extends WebPage
{
	private static final long serialVersionUID = 1L;

	private final String href = "http://wicket.apache.org";

	/**
	 * Construct.
	 */
	public ExternalLinkPage_1()
	{
		add(new ExternalLink("myLink", new PropertyModel(this, "href"))
		{
			public boolean isVisible()
			{
				return ExternalLinkPage_1.this.href.equals("http://wicket.apache.org");
			}
		});
	}
}

Just wrap your href our label in to a PropertyModel, that way they are well reachable from the outside of the ExternalLink.
When ExternalLink is used as an anonymous class href an label are well reachable too, as shown above.
Other ways of using it, or even extending it, I don't quite see.

My guessing on why ExternalLink is implemented like that would be, that ists the simplest possible way to do the job.
It is so minimal that a derived ExternalLink can't even get a glimpse on its own internals from the inside, but it has to fall
back on the class were it was anonymously defined in. Verry minimalistic.
It's just not a real Wicket Link, it is external to the extend that the application doesn't notice when the user clicks it.

I'd say, ask em to close this bug.

> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Priority: Minor
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (WICKET-1016) ExternalLink doesn't use model

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg reassigned WICKET-1016:
-------------------------------------

    Assignee: Igor Vaynberg

> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Assignee: Igor Vaynberg
>            Priority: Minor
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WICKET-1016) ExternalLink doesn't use model

Posted by "Martin Funk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Funk updated WICKET-1016:
--------------------------------

    Attachment: ExternalLink.patch

Hi,

would you mind testing the attached patch ExternalLink.patch to see if it meets you needs?

If it does praise about it.

> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Priority: Minor
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-1016) ExternalLink doesn't use model

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-1016.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3.0-beta4

> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.0-beta4
>
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WICKET-1016) ExternalLink doesn't use model

Posted by "Martin Funk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530929 ] 

Martin Funk commented on WICKET-1016:
-------------------------------------

Hi Tauren,

the error I can't reproduce. I only see the warning.
Looks like I've been coding without reading, maybe I'll comeup with something else on the weekend.

Btw, its not me, its them, who could commit. I'm just doing finger excercises here.

Martin

> ExternalLink doesn't use model
> ------------------------------
>
>                 Key: WICKET-1016
>                 URL: https://issues.apache.org/jira/browse/WICKET-1016
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>            Reporter: Tauren Mills
>            Priority: Minor
>         Attachments: ExternalLink.patch
>
>
> I don't understand why ExternalLink doesn't store the external href as
> the model.  It stores it in an href property.  It seems to not follow
> the normal wicket way.
> This makes it difficult to do things like display a link only if the
> model is not null.  For instance:
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
>        @Override
>        public boolean isVisible() {
>                return getModelObject() != null;
>        }
> });
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property.  And since isVisible()
> is part of Component, the href property isn't accessible.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.