You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Jeremy Gurr <je...@infusionsoft.com> on 2013/08/21 22:51:39 UTC
Removing icon from title in list, and how to properly extend
existing ComponentFactory
We are attempting to control whether the icon next to a title is visible or not through a property of an entity. We couldn't figure out a simple way to do it by reading the documentation or looking through the list of possible annotations, and so we proceeded to try and override the addOrReplaceLinkWrapper method of the EntityIconAndTitlePanel container.
We first tried to subclass it, but the needed method was private so we just copied the entire class, created a ComponentFactory for it, and did a componentFactories.replace(EntityIconAndTitlePanelFactory.class, new EntityIconAndTitlePanelFactoryImproved()) inside of addComponentFactories of ComponentFactoryRegistrarForQuickStart. This failed when we went to list our entities, so we took out our changes so that the new class (EntityIconAndTitleImproved) was exactly the same as the old (EntityIconAndTitle). It was still being constructed by our new Factory, and our new factory is exactly the same as the old with the exception that it constructs the "Improved" class instead of the original inside of createComponent. But it still had the same error. So then we had our new factory construct the old component instead (EntityIconAndTitlePanel), and it worked perfectly fine. So apparently replacing the old component with the new creates this error, even though the new class is identical to the old (except for the class name and package).
So I have two questions. First, is there an easier way to disable the rendering of an icon next to the title of an entity? Second, how do we correctly override a component factory?
As a side note, we did succeed in removing the annoying (to us anyway ;) ) bookmark slide out panel by doing a componentFactories.replace using a subclassed BookmarkedPagesPanelFactory, where createComponent just returns a dummy component. There's probably an easier way to do this too.
We are running the latest git code on the master branch using a project based on the example/application/quickstart_wicket_restful_jdo/.
Here's the stack trace that results from listing our entities:
org.apache.wicket.markup.MarkupNotFoundException
Failed to find markup file associated. EntityIconAndTitlePanelImprovedIcon: [EntityIconAndTitlePanelImprovedIcon [Component id = entityIconAndTitle]]
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy#getMarkup(AssociatedMarkupSourcingStrategy.java:97)
org.apache.wicket.MarkupContainer#getMarkup(MarkupContainer.java:451)
org.apache.wicket.MarkupContainer#renderAssociatedMarkup(MarkupContainer.java:654)
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy#renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)
org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy#onComponentTagBody(PanelMarkupSourcingStrategy.java:112)
org.apache.wicket.Component#internalRenderComponent(Component.java:2549)
org.apache.wicket.MarkupContainer#onRender(MarkupContainer.java:1493)
org.apache.wicket.Component#internalRender(Component.java:2379)
org.apache.wicket.Component#render(Component.java:2307)
org.apache.wicket.MarkupContainer#renderNext(MarkupContainer.java:1390)
org.apache.wicket.MarkupContainer#renderAll(MarkupContainer.java:1554)
org.apache.wicket.MarkupContainer#renderComponentTagBody(MarkupContainer.java:1529)
org.apache.wicket.MarkupContainer#renderAssociatedMarkup(MarkupContainer.java:689)
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy#renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)
org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy#onComponentTagBody(PanelMarkupSourcingStrategy.java:112)
org.apache.wicket.Component#internalRenderComponent(Component.java:2549)
org.apache.wicket.MarkupContainer#onRender(MarkupContainer.java:1493)
org.apache.wicket.Component#internalRender(Component.java:2379)
org.apache.wicket.Component#render(Component.java:2307)
org.apache.wicket.MarkupContainer#renderNext(MarkupContainer.java:1390)
org.apache.wicket.MarkupContainer#renderAll(MarkupContainer.java:1554)
org.apache.wicket.MarkupContainer#renderComponentTagBody(MarkupContainer.java:1529)
org.apache.wicket.MarkupContainer#onComponentTagBody(MarkupContainer.java:1484)
thank you for your time,
Jeremy
Re: Removing icon from title in list, and how to properly extend
existing ComponentFactory
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Just following up on this...
I've just implemented a very simple change [1] to allow
EntityIconAndTitlePanel to be more easily overloaded, if that's what you
want to do.
But, probably more usefully, I've also now written the page on the Isis
site [2] which explains different ways of customizing Isis' Wicket viewer.
Cheers
Dan
[1] https://issues.apache.org/jira/browse/ISIS-500
[2]
http://isis.apache.org/components/viewers/wicket/customizing-the-viewer.html
On 22 August 2013 08:19, Dan Haywood <da...@haywood-associates.co.uk> wrote:
>
>
> On 21 August 2013 21:51, Jeremy Gurr <je...@infusionsoft.com> wrote:
>
> Hi Jeremy,
> Welcome, also, to the Isis mailing list.
>
> We are attempting to control whether the icon next to a title is visible
>> or not through a property of an entity. We couldn't figure out a simple way
>> to do it
>
>
> The easiest way is to use CSS; add the following to
> src/main/webapp/css/application.css:
>
> .entityIconAndTitlePanel a img {
> display: none;
> }
>
>
>
>> by reading the documentation or looking through the list of possible
>> annotations, and so we proceeded to try and override the
>> addOrReplaceLinkWrapper method of the EntityIconAndTitlePanel container.
>>
>> We first tried to subclass it, but the needed method was private so we
>> just copied the entire class,
>
>
> Great to hear you are diving into the implementation and figuring things
> out.
>
> I've just raised ISIS-500 as a ticket to make this particular component
> more easily subclassable (though I'd still probably use CSS myself)
>
>
>
>> [snip]
>>
>>
>> So I have two questions. First, is there an easier way to disable the
>> rendering of an icon next to the title of an entity?
>>
>
> CSS, above
>
>
>> Second, how do we correctly override a component factory?
>>
>>
> You've figured out already how to register your replacement, in
> ComponentFactoryRegistrar. (I'm just writing a new page on the site to
> document this).
>
> Your issue though is a Wicket one: if you have a component called
> EntityIconAndTitlePanelImprovedIcon then there needs to be a HTML page
> called EntityIconAndTitlePanelImprovedIcon.html. You can see this is the
> case for all of Isis' wicket components.
>
>
>
>
>> As a side note, we did succeed in removing the annoying (to us anyway ;)
>> ) bookmark slide out panel by doing a componentFactories.replace
>
>
> Aw... I was quite proud of that!
>
> I agree that sometimes one can accidentally trigger the slide out when
> going to hit "Edit"; perhaps it should be over on the right hand side (or
> configurable as either, maybe).
>
> Before you abandon it, I hope you've noted the feature whereby bookmarks
> can be arranged in a hierarchy through the use of @Bookmarkable(AS_ROOT) or
> @Bookmarkable(AS_CHILD). Any children are automatically attached to their
> parent. That's the bit I'm particularly proud of, because it leverages the
> Isis metamodel to provide better information to the user.
>
> Also, we have some tickets raised to make actions optionally bookmarkable,
> and pinnable, and also limited in number (MRU/LRU).
>
>
>
>
>> using a subclassed BookmarkedPagesPanelFactory, where createComponent
>> just returns a dummy component. There's probably an easier way to do this
>> too.
>>
>
> Yup, probably CSS again.
>
> #bookmarkedPagesSlidingDiv {
> display: none;
> }
> .showPanelTab {
> display: none;
> }
>
>
>
>>
>> We are running the latest git code on the master branch using a project
>> based on the example/application/quickstart_wicket_restful_jdo/.
>>
>> Here's the stack trace that results from listing our entities:
>>
> org.apache.wicket.markup.MarkupNotFoundException
>> Failed to find markup file associated.
>> EntityIconAndTitlePanelImprovedIcon: [EntityIconAndTitlePanelImprovedIcon
>> [Component id = entityIconAndTitle]]
>>
>> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy#getMarkup(AssociatedMarkupSourcingStrategy.java:97)
>>
>
> You can see that Wicket is complaining that it can't find any
> EntityIconAndTitlePanelImprovedIcon.html file.
>
>
> HTH
> Dan
>
>
>
>>
>> thank you for your time,
>>
>> Jeremy
>>
>>
Re: Removing icon from title in list, and how to properly extend
existing ComponentFactory
Posted by Jeremy Gurr <je...@infusionsoft.com>.
The iconName method is not sufficient since we need to pull the data for the image from the entity itself (stored in a Blob object). It is data that is modified at runtime and so can't be in the project resource folder ahead of time. Yes, we could save them to disk but that greatly inhibits scalability of an enterprise app. We did get it working by overriding the EntityIconAndTitleFactory and changing the code that renders the image. Of course it's not terribly fast the first time as the images get loaded and cached, but at this point we are just trying to push the boundaries of the framework to see what is possible.
As a side note, we did discover that if you return an invalid name from the iconName method (an empty string for example), the icon disappears, giving us control over whether the icon appears or not based on certain conditions. I don't know if that is an intended feature or not, but it was one of the things we were looking to figure out how to do.
Jeremy
On Aug 27, 2013, at 11:35 AM, Kevin Meyer - KMZ wrote:
> Hi Jeremy,
>
> I wonder if I'm missing the point, but in the applib you can specify the
> icon for an entity at runtime using the "iconName" method [1][2]
>
> Using that method you can perform any kind of run-time algorithm to
> return the name of the icon file. Unfortunately the file needs to exist
> in one of the default search directories, which is possibly a limiting
> factor.
>
> I suppose that if you want to serve the icons directly from the
> database, you would need to replace the current implementation.
>
> Regards,
> Kevin
>
> [1]
> http://isis.apache.org/applib-guide/how-tos/how-to-01-070-How-to-spe
> cify-the-icon-for-a-domain-entity.html
>
> [2] http://isis.apache.org/applib-guide/how-tos/about.html
>
Re: Removing icon from title in list, and how to properly extend existing ComponentFactory
Posted by Kevin Meyer - KMZ <ke...@kmz.co.za>.
Hi Jeremy,
I wonder if I'm missing the point, but in the applib you can specify the
icon for an entity at runtime using the "iconName" method [1][2]
Using that method you can perform any kind of run-time algorithm to
return the name of the icon file. Unfortunately the file needs to exist
in one of the default search directories, which is possibly a limiting
factor.
I suppose that if you want to serve the icons directly from the
database, you would need to replace the current implementation.
Regards,
Kevin
[1]
http://isis.apache.org/applib-guide/how-tos/how-to-01-070-How-to-spe
cify-the-icon-for-a-domain-entity.html
[2] http://isis.apache.org/applib-guide/how-tos/about.html
On 26 Aug 2013 at 19:54, Jeremy Gurr wrote:
> > Hi Jeremy,
> > Welcome, also, to the Isis mailing list.
>
> Thanks Dan. We are excited for the potential ISIS has for a cleaner separation of concerns between the model and view
> layers than traditional MVC architectures accomplish.
>
> > The easiest way is to use CSS; add the following to
> > src/main/webapp/css/application.css:
> >
> > .entityIconAndTitlePanel a img {
> > display: none;
> > }
>
> That is fine for this example, but our next step is to customize the IconAndTitlePanel to pull the icon out of the
> database, based on images that are uploaded at runtime into a specific property. We've got the images going into the
> database just fine from the property, but now need to make them visible both in the single entity viewer and in the
> collection finders.
Re: Removing icon from title in list, and how to properly extend
existing ComponentFactory
Posted by Jeremy Gurr <je...@infusionsoft.com>.
> Hi Jeremy,
> Welcome, also, to the Isis mailing list.
Thanks Dan. We are excited for the potential ISIS has for a cleaner separation of concerns between the model and view layers than traditional MVC architectures accomplish.
> The easiest way is to use CSS; add the following to
> src/main/webapp/css/application.css:
>
> .entityIconAndTitlePanel a img {
> display: none;
> }
That is fine for this example, but our next step is to customize the IconAndTitlePanel to pull the icon out of the database, based on images that are uploaded at runtime into a specific property. We've got the images going into the database just fine from the property, but now need to make them visible both in the single entity viewer and in the collection finders.
> You've figured out already how to register your replacement, in
> ComponentFactoryRegistrar. (I'm just writing a new page on the site to
> document this).
>
> Your issue though is a Wicket one: if you have a component called
> EntityIconAndTitlePanelImprovedIcon then there needs to be a HTML page
> called EntityIconAndTitlePanelImprovedIcon.html. You can see this is the
> case for all of Isis' wicket components.
So we copied the html page from the original EntityIconAndTitlePanel.html, renaming it to EntityIconAndTitlePanelImprovedIcon.html to match our component name, as well as the css file, and put them in the same package as the factory and component files, but it still gives us the same error message (about missing the markup). Not sure what we are missing here. We are digging deep into wicket documentation to see if we can figure out how that is supposed to work.
>> As a side note, we did succeed in removing the annoying (to us anyway ;) )
>> bookmark slide out panel by doing a componentFactories.replace
>
> Aw... I was quite proud of that!
>
> I agree that sometimes one can accidentally trigger the slide out when
> going to hit "Edit"; perhaps it should be over on the right hand side (or
> configurable as either, maybe).
>
> Before you abandon it, I hope you've noted the feature whereby bookmarks
> can be arranged in a hierarchy through the use of @Bookmarkable(AS_ROOT) or
> @Bookmarkable(AS_CHILD). Any children are automatically attached to their
> parent. That's the bit I'm particularly proud of, because it leverages the
> Isis metamodel to provide better information to the user.
>
> Also, we have some tickets raised to make actions optionally bookmarkable,
> and pinnable, and also limited in number (MRU/LRU).
The bookmark concept itself looks very useful, we just don't like slide outs since they are often sliding out when we don't want them to, and are hard to select when we do want them to if the browser window isn't full screen. We'd prefer a drop down menu or a bread crumb list across the top like eclipse or IDEA uses. Maybe we'll try and implement an alternate view for that eventually...
-- Jeremy
Re: Removing icon from title in list, and how to properly extend
existing ComponentFactory
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 21 August 2013 21:51, Jeremy Gurr <je...@infusionsoft.com> wrote:
Hi Jeremy,
Welcome, also, to the Isis mailing list.
We are attempting to control whether the icon next to a title is visible or
> not through a property of an entity. We couldn't figure out a simple way to
> do it
The easiest way is to use CSS; add the following to
src/main/webapp/css/application.css:
.entityIconAndTitlePanel a img {
display: none;
}
> by reading the documentation or looking through the list of possible
> annotations, and so we proceeded to try and override the
> addOrReplaceLinkWrapper method of the EntityIconAndTitlePanel container.
>
> We first tried to subclass it, but the needed method was private so we
> just copied the entire class,
Great to hear you are diving into the implementation and figuring things
out.
I've just raised ISIS-500 as a ticket to make this particular component
more easily subclassable (though I'd still probably use CSS myself)
> [snip]
>
> So I have two questions. First, is there an easier way to disable the
> rendering of an icon next to the title of an entity?
CSS, above
> Second, how do we correctly override a component factory?
>
>
You've figured out already how to register your replacement, in
ComponentFactoryRegistrar. (I'm just writing a new page on the site to
document this).
Your issue though is a Wicket one: if you have a component called
EntityIconAndTitlePanelImprovedIcon then there needs to be a HTML page
called EntityIconAndTitlePanelImprovedIcon.html. You can see this is the
case for all of Isis' wicket components.
> As a side note, we did succeed in removing the annoying (to us anyway ;) )
> bookmark slide out panel by doing a componentFactories.replace
Aw... I was quite proud of that!
I agree that sometimes one can accidentally trigger the slide out when
going to hit "Edit"; perhaps it should be over on the right hand side (or
configurable as either, maybe).
Before you abandon it, I hope you've noted the feature whereby bookmarks
can be arranged in a hierarchy through the use of @Bookmarkable(AS_ROOT) or
@Bookmarkable(AS_CHILD). Any children are automatically attached to their
parent. That's the bit I'm particularly proud of, because it leverages the
Isis metamodel to provide better information to the user.
Also, we have some tickets raised to make actions optionally bookmarkable,
and pinnable, and also limited in number (MRU/LRU).
> using a subclassed BookmarkedPagesPanelFactory, where createComponent just
> returns a dummy component. There's probably an easier way to do this too.
>
Yup, probably CSS again.
#bookmarkedPagesSlidingDiv {
display: none;
}
.showPanelTab {
display: none;
}
>
> We are running the latest git code on the master branch using a project
> based on the example/application/quickstart_wicket_restful_jdo/.
>
> Here's the stack trace that results from listing our entities:
>
org.apache.wicket.markup.MarkupNotFoundException
> Failed to find markup file associated.
> EntityIconAndTitlePanelImprovedIcon: [EntityIconAndTitlePanelImprovedIcon
> [Component id = entityIconAndTitle]]
>
> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy#getMarkup(AssociatedMarkupSourcingStrategy.java:97)
>
You can see that Wicket is complaining that it can't find any
EntityIconAndTitlePanelImprovedIcon.html file.
HTH
Dan
>
> thank you for your time,
>
> Jeremy
>
>