You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Alexander Zerbe <ze...@prime-research.com> on 2016/08/12 09:56:42 UTC

URLs as property.

Hi Everyone,

I have a (hopefully) simple problem. 
A domain entity has a URL as property - I'm searching for a way too
make those URLs clickable when displayed in a collection.

For example:
I want to list a subset of those entitys and from there I want the 
possibility to click the link and get redirected.

Returning a URL from an action works (but only for http(s) URLs, not
for file://), but thats not what I want. 

The only solution I see (so far), is too create a seperate wicket page
with mountPage().

It would also be okay too just have the name of the object and if I
click it, I get redirected immediatly.


I'm up for any suggestions.


Best regards

Re: URLs as property.

Posted by Kevin Meyer <ke...@kmz.co.za>.
Hi Martin, 
Excellent suggestion! You would have solved the same problem there. 
I will look into that and post the results to my github account. 

Thanks, 
Kevin

On 22 August 2016 16:55:20 CEST, Martin Grigorov <mg...@apache.org> wrote:
>Hi Kevin,
>
>You can take some inspiration from https://github.com/
>isisaddons/isis-wicket-summernote/tree/master/cpt/
>src/main/java/org/isisaddons/wicket/summernote/cpt/applib.
>This component uses custom annotation @SummernoteEditor that could be
>applied on java.lang.String properties to show their edit mode in a
>rich
>editor (http://summernote.org/)
>
>Martin Grigorov
>Wicket Training and Consulting
>https://twitter.com/mtgrigorov
>
>On Sun, Aug 21, 2016 at 5:00 PM, Kevin Meyer <ke...@kmz.co.za> wrote:
>
>> Hi Alexander,
>>
>> If I understand you correctly, I have a solution that could work.
>>
>> When viewed as an item (by iteself), the URL is just a plain string
>that
>> can be edited.
>>
>> When viewed in a collection, the URLs are rendered as links (but for
>some
>> reason my Firefox does not actually respond when I click on the URL,
>but
>> all the mark-up seems OK).
>>
>> See bottom for the Factory, which must be added to
>> META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory
>> e.g. mine is:
>> isis.example.UrlPanelFactory
>>
>> Hi Martin,
>>
>> With the following Java:
>> /**
>>  * Panel for rendering strings as links.
>>  */
>> public class UrlPanel extends ScalarPanelTextFieldParseableAbstract {
>>     private static final long serialVersionUID = 1L;
>>     private static final String ID_LINK = "externalSite";
>>
>>
>>     public UrlPanel(final String id, final ScalarModel scalarModel) {
>>         super(id, ID_SCALAR_VALUE, scalarModel);
>>     }
>>
>>     @Override
>>     protected IModel<String> getScalarPanelType() {
>>         return Model.of("stringPanel");
>>     }
>>
>>     @Override
>>     protected Component addComponentForCompact() {
>>         System.out.println("addComponentForCompact()");
>>         Fragment compactFragment =
>getCompactFragment(CompactType.SPAN);
>>         final String objectAsString = getModel().getObjectAsString();
>>         final ExternalLink link = new ExternalLink(ID_LINK,
>> objectAsString, objectAsString);
>>         compactFragment.add(link);
>>         scalarTypeContainer.addOrReplace(compactFragment);
>>         return link;
>>     }
>> }
>>
>>
>> I found that I had to overload most of the ScalarPanelAbstract.html
>and
>> the ScalarPanelTextFieldAbstract.html to create:
>>
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml"
>>       xmlns:wicket="http://wicket.apache.org"
>>       xml:lang="en"
>>       lang="en">
>>     <body>
>>                 <wicket:panel>
>>             <div class="scalarNameAndValueComponentType"
>> wicket:id="scalarTypeContainer">
>>                 <div class="form-group" wicket:id="scalarIfRegular">
>>                     <label wicket:id="scalarName" class="scalarName
>> control-label">[Label text]</label>
>>                     <span class="scalarValueWrapper">
>>                         <div class="scalarPlaceholder">
>>                             <span class="scalarValueInput">
>>                                 <span class="editing">
>>                                     <wicket:child/>
>>
>>       <wicket:container wicket:id="scalarValueContainer"/>
>>                                     <a wicket:id="editProperty"
>href="#"
>> class="edit fa fa-pencil-square-o"/>
>>                                 </span>
>>                             </span>
>>                             <span
>wicket:id="associatedActionLinksRight"
>> class="associatedActionLinksRight">[drop
>> down]</span>
>>                         </div>
>>                         <span wicket:id="feedback"
>> class="help-block"></span>
>>                         <span wicket:id="associatedActionLin
>> ksBelow"></span>
>>                     </span>
>>                     <div class="clearfix"/>
>>                 </div>
>>                 <wicket:container wicket:id="scalarIfCompact">
>>                 </wicket:container>
>>             </div>
>>
>>             <wicket:fragment wicket:id="text">
>>                 <input type="text" name="scalarValue"
>class="form-control
>> input-sm scalarValue" wicket:id="scalarValue" />
>>             </wicket:fragment>
>>
>>             <wicket:fragment wicket:id="compactAsSpan">
>>                 <a wicket:id="externalSite"></a>
>>             </wicket:fragment>
>>                 </wicket:panel>
>>     </body>
>> </html>
>>
>>
>> Finally, the factory. This is a horrible hack.
>> Basically, I check for any string property that starts with "url".
>> Ideally this should be an annotation or something, but I could not
>figure
>> out how to pick up annotations from the property in the "aapliesTo"
>method
>> of the factory:
>>
>>
>> public class UrlPanelFactory extends ComponentFactoryScalarAbstract {
>>
>>     private static final long serialVersionUID = 1L;
>>
>>     public UrlPanelFactory() {
>>         super(String.class);
>>     }
>>
>>     @Override
>>     public ApplicationAdvice appliesTo(IModel<?> model) {
>>         if (!(model instanceof ScalarModel)) {
>>             return ApplicationAdvice.DOES_NOT_APPLY;
>>         }
>>
>>         ScalarModel scalarModel = (ScalarModel) model;
>>         PropertyMemento memento = scalarModel.getPropertyMemento();
>>         if (memento != null){
>>                 String identifier = memento.getIdentifier();
>>                 final ApplicationAdvice appliesIf =
>> appliesIf(identifier.startsWith("url"));
>>                         return appliesIf;
>>         }
>>         return ApplicationAdvice.DOES_NOT_APPLY;
>>     }
>>
>>
>>     @Override
>>     public Component createComponent(final String id, final
>ScalarModel
>> scalarModel) {
>>         return new UrlPanel(id, scalarModel);
>>     }
>>
>>     protected SpecificationLoader getSpecificationLoader() {
>>         return
>IsisContext.getSessionFactory().getSpecificationLoader();
>>     }
>> }
>>
>>
>>
>>
>> On Sat, August 20, 2016 13:08, Martin Grigorov wrote:
>> > Hi Kevin,
>> >
>> >
>> >
>> > On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za>
>wrote:
>> >
>> >
>> >> Hi Alexander,
>> >>
>> >>
>> >> I thought the trick here was to register a new ScalarPanelAbstract
>that
>> >>  would pick up the URL and render it as a click-able link.
>> >>
>> >> In my testing, I have been able to register my
>> >> "isis.example.UrlPanelFactory", which is just a String renderer
>(copied
>> >> from ShortPanel).
>> >>
>> >> However, I have reached my limit. I can parse the text value,
>detect
>> >> that it is a URL, but now I can't figure out how to create the
>matching
>> >> Wicket
>> >> HTML and Java to populate a hyperlink!
>> >>
>> >>
>> >> I was experimenting with the HTML:
>> >>
>> >>
>> >> <wicket:panel>
>> >> <div class="shortPanel
>> >> scalarNameAndValueComponentType"> <label for="scalarValue"
>> >> wicket:id="scalarIfRegular">
>> >> <span wicket:id="scalarName"
>> >> class="scalarName">[Label text]</span> <span class="scalarValue">
>> >> <input type="text"
>> >> name="scalarValue" wicket:id="scalarValue" /> <span
>> >> wicket:id="feedback"></span>
>> >> </span>
>> >> </label>
>> >> <input type="text"
>> >> wicket:id="scalarIfCompact"></input>
>> >>
>> >>
>> >
>> > This should not be <input>.
>> > "scalarIfCompact" is used for the "view" mode, "scalarIfRegular"
>for the
>> > "edit" mode.
>> > I.e. in edit mode you have to use <input> to change the url, in
>view mode
>> > you have to use <a> to be able to click it.
>> >
>> >
>> >> <!--
>> >> <span wicket:id="scalarUrl">
>> >> <a href='a'
>> >> wicket:id="scalarUrl"><input type="text"
>> >> wicket:id="scalarUrl"></input></a>
>> >>
>> >>
>> >
>> > Remove <input> here too.
>> >
>> >
>> >
>> >> </span>
>> >> -->
>> >> </div>
>> >> </wicket:panel>
>> >>
>> >>
>> >> But I don't know how to update the Java:
>> >> public class UrlPanel extends ScalarPanelAbstract { ...
>> >> // How to manipulate the Wicket component, once I have my
>URL-containing
>> >>  string.
>> >>
>> >
>> > You need to extend #getLabelForCompact() and
>#getComponentForRegular() (
>> > https://github.com/apache/isis/blob/501e890f90d535df43d73a90
>> e14295fadc9f9b
>> > 64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewe
>> r/wicket/ui/c
>> > omponents/scalars/ScalarPanelAbstract.java#L171-L177 )
>> > For the link (<a wicket:id="scalarUrl">) you can use Wicket's
>> ExternalLink
>> >  component. For <span wicket:id="scalarUrl"> use
>WebMarkupContainer, if
>> > you really need it to be Wicket component. Otherwise just remove
>> wicket:id
>> > from it.
>> >
>> > Try it and let me know if you face any problems!
>> >
>> >
>> >> ...
>> >> }
>> >>
>> >>
>> >>
>> >> Maybe someone with better Wicket foo can provide some advice...
>> >>
>> >>
>> >> Cheers,
>> >> Kevin
>> >>
>> >>
>> >>
>> >> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
>> >>
>> >>>
>> >>
>> >>>>>
>> >>>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
>> >>>>>> <ze...@prime-research.com> wrote:
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> Hi Everyone,
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> I have a (hopefully) simple problem.
>> >>>>>> A domain entity has a URL as property - I'm searching for a
>way
>> >>>>>> too make those URLs clickable when displayed in a collection.
>> >>>>>>
>> >>>>>> For example:
>> >>>>>> I want to list a subset of those entitys and from there I want
>> >>>>>> the possibility to click the link and get redirected.
>> >>>>>>
>> >>>>>> Returning a URL from an action works (but only for http(s)
>> >>>>>> URLs,
>> >>>>>> not for file://), but thats not what I want.
>> >>>>>>
>> >>>>>> The only solution I see (so far), is too create a seperate
>> >>>>>> wicket page with mountPage().
>> >>>>>>
>> >>>>>> It would also be okay too just have the name of the object and
>> >>>>>> if I click it, I get redirected immediatly.
>> >>>>>>
>> >>>>>>
>> >>>>>> I'm up for any suggestions.
>> >>>>>>
>>
>>
>>

-- 
Sent from my phone with K-9 Mail.
Please excuse my brevity.

Re: URLs as property.

Posted by Martin Grigorov <mg...@apache.org>.
Well done, Kevin!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Aug 25, 2016 at 8:40 PM, Kevin Meyer <ke...@kmz.co.za> wrote:

> Hi all,
>
> To wrap this up, I have followed Martin's hints from his Summernote
> project and created an example for how I made a String property into
> click-able URLs when viewed in a collection.
>
> I'm sure just a little more Wicket foo would add a similar link to these
> properties when viewed in isolation, but my focus was on Alexander's
> original problem (as I understood it - Alexander, can you confirm?).
>
> In any case, I have put the instructions and code into my github project:
> https://github.com/kev-m/isis-wicket-url/
>
> Enjoy!
>
> Feel free to use, re-use, modify and especially improve (with pull
> requests).
>
> Regards,
> Kevin
>
>
> On Mon, August 22, 2016 16:55, Martin Grigorov wrote:
> > Hi Kevin,
> >
> >
> > You can take some inspiration from https://github.com/
> > isisaddons/isis-wicket-summernote/tree/master/cpt/
> > src/main/java/org/isisaddons/wicket/summernote/cpt/applib. This
> component
> > uses custom annotation @SummernoteEditor that could be applied on
> > java.lang.String properties to show their edit mode in a rich editor
> > (http://summernote.org/)
> >
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> >
> > On Sun, Aug 21, 2016 at 5:00 PM, Kevin Meyer <ke...@kmz.co.za> wrote:
> >
> >
> >> Hi Alexander,
> >>
> >>
> >> If I understand you correctly, I have a solution that could work.
> >>
> >>
> >> When viewed as an item (by iteself), the URL is just a plain string
> >> that can be edited.
> >>
> >> When viewed in a collection, the URLs are rendered as links (but for
> >> some reason my Firefox does not actually respond when I click on the
> >> URL, but
> >> all the mark-up seems OK).
> >>
> >> See bottom for the Factory, which must be added to
> >> META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory
> >> e.g. mine is: isis.example.UrlPanelFactory
> >>
> >> Hi Martin,
> >>
> >>
> >> With the following Java:
> >> /**
> >> * Panel for rendering strings as links.
> >> */
> >> public class UrlPanel extends ScalarPanelTextFieldParseableAbstract {
> >> private static final long serialVersionUID = 1L; private static final
> >> String ID_LINK = "externalSite";
> >>
> >>
> >>
> >> public UrlPanel(final String id, final ScalarModel scalarModel) {
> >> super(id, ID_SCALAR_VALUE, scalarModel); }
> >>
> >>
> >> @Override
> >> protected IModel<String> getScalarPanelType() { return
> >> Model.of("stringPanel");
> >> }
> >>
> >>
> >> @Override
> >> protected Component addComponentForCompact() {
> >> System.out.println("addComponentForCompact()");
> >> Fragment compactFragment = getCompactFragment(CompactType.SPAN);
> >> final String objectAsString = getModel().getObjectAsString(); final
> >> ExternalLink link = new ExternalLink(ID_LINK,
> >> objectAsString, objectAsString); compactFragment.add(link);
> >> scalarTypeContainer.addOrReplace(compactFragment); return link; }
> >> }
> >>
> >>
> >>
> >> I found that I had to overload most of the ScalarPanelAbstract.html and
> >>  the ScalarPanelTextFieldAbstract.html to create:
> >>
> >>
> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> >> <html xmlns="http://www.w3.org/1999/xhtml"
> >> xmlns:wicket="http://wicket.apache.org"
> >> xml:lang="en"
> >> lang="en"> <body>
> >> <wicket:panel>
> >> <div class="scalarNameAndValueComponentType"
> >> wicket:id="scalarTypeContainer">
> >> <div class="form-group" wicket:id="scalarIfRegular">
> >> <label wicket:id="scalarName" class="scalarName
> >> control-label">[Label text]</label> <span class="scalarValueWrapper">
> >> <div class="scalarPlaceholder">
> >> <span class="scalarValueInput">
> >> <span class="editing">
> >> <wicket:child/>
> >>
> >>
> >> <wicket:container wicket:id="scalarValueContainer"/>
> >> <a wicket:id="editProperty" href="#"
> >> class="edit fa fa-pencil-square-o"/> </span>
> >> </span>
> >> <span wicket:id="associatedActionLinksRight"
> >> class="associatedActionLinksRight">[drop down]</span> </div>
> >> <span wicket:id="feedback"
> >> class="help-block"></span> <span wicket:id="associatedActionLin
> >> ksBelow"></span> </span>
> >> <div class="clearfix"/>
> >> </div>
> >> <wicket:container wicket:id="scalarIfCompact">
> >> </wicket:container>
> >> </div>
> >>
> >>
> >> <wicket:fragment wicket:id="text">
> >> <input type="text" name="scalarValue" class="form-control
> >> input-sm scalarValue" wicket:id="scalarValue" /> </wicket:fragment>
> >>
> >>
> >> <wicket:fragment wicket:id="compactAsSpan">
> >> <a wicket:id="externalSite"></a>
> >> </wicket:fragment>
> >> </wicket:panel>
> >> </body>
> >> </html>
> >>
> >>
> >>
> >> Finally, the factory. This is a horrible hack.
> >> Basically, I check for any string property that starts with "url".
> >> Ideally this should be an annotation or something, but I could not
> >> figure out how to pick up annotations from the property in the
> >> "aapliesTo" method
> >> of the factory:
> >>
> >>
> >> public class UrlPanelFactory extends ComponentFactoryScalarAbstract {
> >>
> >> private static final long serialVersionUID = 1L;
> >>
> >> public UrlPanelFactory() { super(String.class); }
> >>
> >>
> >> @Override
> >> public ApplicationAdvice appliesTo(IModel<?> model) { if (!(model
> >> instanceof ScalarModel)) { return ApplicationAdvice.DOES_NOT_APPLY; }
> >>
> >>
> >> ScalarModel scalarModel = (ScalarModel) model;
> >> PropertyMemento memento = scalarModel.getPropertyMemento();
> >> if (memento != null){ String identifier = memento.getIdentifier();
> >> final ApplicationAdvice appliesIf =
> >> appliesIf(identifier.startsWith("url")); return appliesIf; }
> >> return ApplicationAdvice.DOES_NOT_APPLY; }
> >>
> >>
> >>
> >> @Override
> >> public Component createComponent(final String id, final ScalarModel
> >> scalarModel) { return new UrlPanel(id, scalarModel); }
> >>
> >>
> >> protected SpecificationLoader getSpecificationLoader() { return
> >> IsisContext.getSessionFactory().getSpecificationLoader();
> >> }
> >> }
> >>
> >>
> >>
> >>
> >>
> >> On Sat, August 20, 2016 13:08, Martin Grigorov wrote:
> >>
> >>> Hi Kevin,
> >>>
> >>>
> >>>
> >>>
> >>> On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za>
> >>> wrote:
> >>>
> >>>
> >>>
> >>>> Hi Alexander,
> >>>>
> >>>>
> >>>>
> >>>> I thought the trick here was to register a new ScalarPanelAbstract
> >>>> that would pick up the URL and render it as a click-able link.
> >>>>
> >>>> In my testing, I have been able to register my
> >>>> "isis.example.UrlPanelFactory", which is just a String renderer
> >>>> (copied
> >>>> from ShortPanel).
> >>>>
> >>>> However, I have reached my limit. I can parse the text value,
> >>>> detect that it is a URL, but now I can't figure out how to create
> >>>> the matching Wicket
> >>>> HTML and Java to populate a hyperlink!
> >>>>
> >>>>
> >>>>
> >>>> I was experimenting with the HTML:
> >>>>
> >>>>
> >>>>
> >>>> <wicket:panel>
> >>>> <div class="shortPanel
> >>>> scalarNameAndValueComponentType"> <label for="scalarValue"
> >>>> wicket:id="scalarIfRegular">
> >>>> <span wicket:id="scalarName"
> >>>> class="scalarName">[Label text]</span> <span class="scalarValue">
> >>>> <input type="text"
> >>>> name="scalarValue" wicket:id="scalarValue" /> <span
> >>>> wicket:id="feedback"></span>
> >>>> </span>
> >>>> </label>
> >>>> <input type="text"
> >>>> wicket:id="scalarIfCompact"></input>
> >>>>
> >>>>
> >>>>
> >>>
> >>> This should not be <input>.
> >>> "scalarIfCompact" is used for the "view" mode, "scalarIfRegular" for
> >>> the "edit" mode.
> >>> I.e. in edit mode you have to use <input> to change the url, in view
> >>> mode you have to use <a> to be able to click it.
> >>>
> >>>
> >>>> <!--
> >>>> <span wicket:id="scalarUrl">
> >>>> <a href='a'
> >>>> wicket:id="scalarUrl"><input type="text"
> >>>> wicket:id="scalarUrl"></input></a>
> >>>>
> >>>>
> >>>>
> >>>
> >>> Remove <input> here too.
> >>>
> >>>
> >>>
> >>>
> >>>> </span>
> >>>> -->
> >>>> </div>
> >>>> </wicket:panel>
> >>>>
> >>>>
> >>>>
> >>>> But I don't know how to update the Java:
> >>>> public class UrlPanel extends ScalarPanelAbstract { ... // How to
> >>>> manipulate the Wicket component, once I have my URL-containing
> >>>> string.
> >>>>
> >>>
> >>> You need to extend #getLabelForCompact() and
> >>> #getComponentForRegular() (
> >>> https://github.com/apache/isis/blob/501e890f90d535df43d73a90
> >>>
> >> e14295fadc9f9b
> >>> 64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewe
> >>>
> >> r/wicket/ui/c
> >>> omponents/scalars/ScalarPanelAbstract.java#L171-L177 ) For the link
> >>> (<a wicket:id="scalarUrl">) you can use Wicket's
> >>>
> >> ExternalLink
> >>
> >>> component. For <span wicket:id="scalarUrl"> use WebMarkupContainer,
> >>> if you really need it to be Wicket component. Otherwise just remove
> >> wicket:id
> >>
> >>> from it.
> >>>
> >>> Try it and let me know if you face any problems!
> >>>
> >>>
> >>>
> >>>> ...
> >>>> }
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> Maybe someone with better Wicket foo can provide some advice...
> >>>>
> >>>>
> >>>>
> >>>> Cheers,
> >>>> Kevin
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
> >>>>
> >>>>
> >>>>>
> >>>>
> >>>>>>>
> >>>>>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
> >>>>>>>> <ze...@prime-research.com> wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Hi Everyone,
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> I have a (hopefully) simple problem.
> >>>>>>>> A domain entity has a URL as property - I'm searching for a
> >>>>>>>> way too make those URLs clickable when displayed in a
> >>>>>>>> collection.
> >>>>>>>>
> >>>>>>>> For example:
> >>>>>>>> I want to list a subset of those entitys and from there I
> >>>>>>>> want the possibility to click the link and get redirected.
> >>>>>>>>
> >>>>>>>> Returning a URL from an action works (but only for http(s)
> >>>>>>>> URLs,
> >>>>>>>> not for file://), but thats not what I want.
> >>>>>>>>
> >>>>>>>> The only solution I see (so far), is too create a seperate
> >>>>>>>> wicket page with mountPage().
> >>>>>>>>
> >>>>>>>> It would also be okay too just have the name of the object
> >>>>>>>> and if I click it, I get redirected immediatly.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> I'm up for any suggestions.
> >>>>>>>>
> >>>>>>>>
> >>
> >>
>
>
>

Re: URLs as property.

Posted by Kevin Meyer <ke...@kmz.co.za>.
Hi all,

To wrap this up, I have followed Martin's hints from his Summernote
project and created an example for how I made a String property into
click-able URLs when viewed in a collection.

I'm sure just a little more Wicket foo would add a similar link to these
properties when viewed in isolation, but my focus was on Alexander's
original problem (as I understood it - Alexander, can you confirm?).

In any case, I have put the instructions and code into my github project:
https://github.com/kev-m/isis-wicket-url/

Enjoy!

Feel free to use, re-use, modify and especially improve (with pull requests).

Regards,
Kevin


On Mon, August 22, 2016 16:55, Martin Grigorov wrote:
> Hi Kevin,
>
>
> You can take some inspiration from https://github.com/
> isisaddons/isis-wicket-summernote/tree/master/cpt/
> src/main/java/org/isisaddons/wicket/summernote/cpt/applib. This component
> uses custom annotation @SummernoteEditor that could be applied on
> java.lang.String properties to show their edit mode in a rich editor
> (http://summernote.org/)
>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
>
> On Sun, Aug 21, 2016 at 5:00 PM, Kevin Meyer <ke...@kmz.co.za> wrote:
>
>
>> Hi Alexander,
>>
>>
>> If I understand you correctly, I have a solution that could work.
>>
>>
>> When viewed as an item (by iteself), the URL is just a plain string
>> that can be edited.
>>
>> When viewed in a collection, the URLs are rendered as links (but for
>> some reason my Firefox does not actually respond when I click on the
>> URL, but
>> all the mark-up seems OK).
>>
>> See bottom for the Factory, which must be added to
>> META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory
>> e.g. mine is: isis.example.UrlPanelFactory
>>
>> Hi Martin,
>>
>>
>> With the following Java:
>> /**
>> * Panel for rendering strings as links.
>> */
>> public class UrlPanel extends ScalarPanelTextFieldParseableAbstract {
>> private static final long serialVersionUID = 1L; private static final
>> String ID_LINK = "externalSite";
>>
>>
>>
>> public UrlPanel(final String id, final ScalarModel scalarModel) {
>> super(id, ID_SCALAR_VALUE, scalarModel); }
>>
>>
>> @Override
>> protected IModel<String> getScalarPanelType() { return
>> Model.of("stringPanel");
>> }
>>
>>
>> @Override
>> protected Component addComponentForCompact() {
>> System.out.println("addComponentForCompact()");
>> Fragment compactFragment = getCompactFragment(CompactType.SPAN);
>> final String objectAsString = getModel().getObjectAsString(); final
>> ExternalLink link = new ExternalLink(ID_LINK,
>> objectAsString, objectAsString); compactFragment.add(link);
>> scalarTypeContainer.addOrReplace(compactFragment); return link; }
>> }
>>
>>
>>
>> I found that I had to overload most of the ScalarPanelAbstract.html and
>>  the ScalarPanelTextFieldAbstract.html to create:
>>
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>> <html xmlns="http://www.w3.org/1999/xhtml"
>> xmlns:wicket="http://wicket.apache.org"
>> xml:lang="en"
>> lang="en"> <body>
>> <wicket:panel>
>> <div class="scalarNameAndValueComponentType"
>> wicket:id="scalarTypeContainer">
>> <div class="form-group" wicket:id="scalarIfRegular">
>> <label wicket:id="scalarName" class="scalarName
>> control-label">[Label text]</label> <span class="scalarValueWrapper">
>> <div class="scalarPlaceholder">
>> <span class="scalarValueInput">
>> <span class="editing">
>> <wicket:child/>
>>
>>
>> <wicket:container wicket:id="scalarValueContainer"/>
>> <a wicket:id="editProperty" href="#"
>> class="edit fa fa-pencil-square-o"/> </span>
>> </span>
>> <span wicket:id="associatedActionLinksRight"
>> class="associatedActionLinksRight">[drop down]</span> </div>
>> <span wicket:id="feedback"
>> class="help-block"></span> <span wicket:id="associatedActionLin
>> ksBelow"></span> </span>
>> <div class="clearfix"/>
>> </div>
>> <wicket:container wicket:id="scalarIfCompact">
>> </wicket:container>
>> </div>
>>
>>
>> <wicket:fragment wicket:id="text">
>> <input type="text" name="scalarValue" class="form-control
>> input-sm scalarValue" wicket:id="scalarValue" /> </wicket:fragment>
>>
>>
>> <wicket:fragment wicket:id="compactAsSpan">
>> <a wicket:id="externalSite"></a>
>> </wicket:fragment>
>> </wicket:panel>
>> </body>
>> </html>
>>
>>
>>
>> Finally, the factory. This is a horrible hack.
>> Basically, I check for any string property that starts with "url".
>> Ideally this should be an annotation or something, but I could not
>> figure out how to pick up annotations from the property in the
>> "aapliesTo" method
>> of the factory:
>>
>>
>> public class UrlPanelFactory extends ComponentFactoryScalarAbstract {
>>
>> private static final long serialVersionUID = 1L;
>>
>> public UrlPanelFactory() { super(String.class); }
>>
>>
>> @Override
>> public ApplicationAdvice appliesTo(IModel<?> model) { if (!(model
>> instanceof ScalarModel)) { return ApplicationAdvice.DOES_NOT_APPLY; }
>>
>>
>> ScalarModel scalarModel = (ScalarModel) model;
>> PropertyMemento memento = scalarModel.getPropertyMemento();
>> if (memento != null){ String identifier = memento.getIdentifier();
>> final ApplicationAdvice appliesIf =
>> appliesIf(identifier.startsWith("url")); return appliesIf; }
>> return ApplicationAdvice.DOES_NOT_APPLY; }
>>
>>
>>
>> @Override
>> public Component createComponent(final String id, final ScalarModel
>> scalarModel) { return new UrlPanel(id, scalarModel); }
>>
>>
>> protected SpecificationLoader getSpecificationLoader() { return
>> IsisContext.getSessionFactory().getSpecificationLoader();
>> }
>> }
>>
>>
>>
>>
>>
>> On Sat, August 20, 2016 13:08, Martin Grigorov wrote:
>>
>>> Hi Kevin,
>>>
>>>
>>>
>>>
>>> On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za>
>>> wrote:
>>>
>>>
>>>
>>>> Hi Alexander,
>>>>
>>>>
>>>>
>>>> I thought the trick here was to register a new ScalarPanelAbstract
>>>> that would pick up the URL and render it as a click-able link.
>>>>
>>>> In my testing, I have been able to register my
>>>> "isis.example.UrlPanelFactory", which is just a String renderer
>>>> (copied
>>>> from ShortPanel).
>>>>
>>>> However, I have reached my limit. I can parse the text value,
>>>> detect that it is a URL, but now I can't figure out how to create
>>>> the matching Wicket
>>>> HTML and Java to populate a hyperlink!
>>>>
>>>>
>>>>
>>>> I was experimenting with the HTML:
>>>>
>>>>
>>>>
>>>> <wicket:panel>
>>>> <div class="shortPanel
>>>> scalarNameAndValueComponentType"> <label for="scalarValue"
>>>> wicket:id="scalarIfRegular">
>>>> <span wicket:id="scalarName"
>>>> class="scalarName">[Label text]</span> <span class="scalarValue">
>>>> <input type="text"
>>>> name="scalarValue" wicket:id="scalarValue" /> <span
>>>> wicket:id="feedback"></span>
>>>> </span>
>>>> </label>
>>>> <input type="text"
>>>> wicket:id="scalarIfCompact"></input>
>>>>
>>>>
>>>>
>>>
>>> This should not be <input>.
>>> "scalarIfCompact" is used for the "view" mode, "scalarIfRegular" for
>>> the "edit" mode.
>>> I.e. in edit mode you have to use <input> to change the url, in view
>>> mode you have to use <a> to be able to click it.
>>>
>>>
>>>> <!--
>>>> <span wicket:id="scalarUrl">
>>>> <a href='a'
>>>> wicket:id="scalarUrl"><input type="text"
>>>> wicket:id="scalarUrl"></input></a>
>>>>
>>>>
>>>>
>>>
>>> Remove <input> here too.
>>>
>>>
>>>
>>>
>>>> </span>
>>>> -->
>>>> </div>
>>>> </wicket:panel>
>>>>
>>>>
>>>>
>>>> But I don't know how to update the Java:
>>>> public class UrlPanel extends ScalarPanelAbstract { ... // How to
>>>> manipulate the Wicket component, once I have my URL-containing
>>>> string.
>>>>
>>>
>>> You need to extend #getLabelForCompact() and
>>> #getComponentForRegular() (
>>> https://github.com/apache/isis/blob/501e890f90d535df43d73a90
>>>
>> e14295fadc9f9b
>>> 64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewe
>>>
>> r/wicket/ui/c
>>> omponents/scalars/ScalarPanelAbstract.java#L171-L177 ) For the link
>>> (<a wicket:id="scalarUrl">) you can use Wicket's
>>>
>> ExternalLink
>>
>>> component. For <span wicket:id="scalarUrl"> use WebMarkupContainer,
>>> if you really need it to be Wicket component. Otherwise just remove
>> wicket:id
>>
>>> from it.
>>>
>>> Try it and let me know if you face any problems!
>>>
>>>
>>>
>>>> ...
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> Maybe someone with better Wicket foo can provide some advice...
>>>>
>>>>
>>>>
>>>> Cheers,
>>>> Kevin
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
>>>>
>>>>
>>>>>
>>>>
>>>>>>>
>>>>>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
>>>>>>>> <ze...@prime-research.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi Everyone,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> I have a (hopefully) simple problem.
>>>>>>>> A domain entity has a URL as property - I'm searching for a
>>>>>>>> way too make those URLs clickable when displayed in a
>>>>>>>> collection.
>>>>>>>>
>>>>>>>> For example:
>>>>>>>> I want to list a subset of those entitys and from there I
>>>>>>>> want the possibility to click the link and get redirected.
>>>>>>>>
>>>>>>>> Returning a URL from an action works (but only for http(s)
>>>>>>>> URLs,
>>>>>>>> not for file://), but thats not what I want.
>>>>>>>>
>>>>>>>> The only solution I see (so far), is too create a seperate
>>>>>>>> wicket page with mountPage().
>>>>>>>>
>>>>>>>> It would also be okay too just have the name of the object
>>>>>>>> and if I click it, I get redirected immediatly.
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm up for any suggestions.
>>>>>>>>
>>>>>>>>
>>
>>



Re: URLs as property.

Posted by Martin Grigorov <mg...@apache.org>.
Hi Kevin,

You can take some inspiration from https://github.com/
isisaddons/isis-wicket-summernote/tree/master/cpt/
src/main/java/org/isisaddons/wicket/summernote/cpt/applib.
This component uses custom annotation @SummernoteEditor that could be
applied on java.lang.String properties to show their edit mode in a rich
editor (http://summernote.org/)

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Sun, Aug 21, 2016 at 5:00 PM, Kevin Meyer <ke...@kmz.co.za> wrote:

> Hi Alexander,
>
> If I understand you correctly, I have a solution that could work.
>
> When viewed as an item (by iteself), the URL is just a plain string that
> can be edited.
>
> When viewed in a collection, the URLs are rendered as links (but for some
> reason my Firefox does not actually respond when I click on the URL, but
> all the mark-up seems OK).
>
> See bottom for the Factory, which must be added to
> META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory
> e.g. mine is:
> isis.example.UrlPanelFactory
>
> Hi Martin,
>
> With the following Java:
> /**
>  * Panel for rendering strings as links.
>  */
> public class UrlPanel extends ScalarPanelTextFieldParseableAbstract {
>     private static final long serialVersionUID = 1L;
>     private static final String ID_LINK = "externalSite";
>
>
>     public UrlPanel(final String id, final ScalarModel scalarModel) {
>         super(id, ID_SCALAR_VALUE, scalarModel);
>     }
>
>     @Override
>     protected IModel<String> getScalarPanelType() {
>         return Model.of("stringPanel");
>     }
>
>     @Override
>     protected Component addComponentForCompact() {
>         System.out.println("addComponentForCompact()");
>         Fragment compactFragment = getCompactFragment(CompactType.SPAN);
>         final String objectAsString = getModel().getObjectAsString();
>         final ExternalLink link = new ExternalLink(ID_LINK,
> objectAsString, objectAsString);
>         compactFragment.add(link);
>         scalarTypeContainer.addOrReplace(compactFragment);
>         return link;
>     }
> }
>
>
> I found that I had to overload most of the ScalarPanelAbstract.html and
> the ScalarPanelTextFieldAbstract.html to create:
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:wicket="http://wicket.apache.org"
>       xml:lang="en"
>       lang="en">
>     <body>
>                 <wicket:panel>
>             <div class="scalarNameAndValueComponentType"
> wicket:id="scalarTypeContainer">
>                 <div class="form-group" wicket:id="scalarIfRegular">
>                     <label wicket:id="scalarName" class="scalarName
> control-label">[Label text]</label>
>                     <span class="scalarValueWrapper">
>                         <div class="scalarPlaceholder">
>                             <span class="scalarValueInput">
>                                 <span class="editing">
>                                     <wicket:child/>
>
>       <wicket:container wicket:id="scalarValueContainer"/>
>                                     <a wicket:id="editProperty" href="#"
> class="edit fa fa-pencil-square-o"/>
>                                 </span>
>                             </span>
>                             <span wicket:id="associatedActionLinksRight"
> class="associatedActionLinksRight">[drop
> down]</span>
>                         </div>
>                         <span wicket:id="feedback"
> class="help-block"></span>
>                         <span wicket:id="associatedActionLin
> ksBelow"></span>
>                     </span>
>                     <div class="clearfix"/>
>                 </div>
>                 <wicket:container wicket:id="scalarIfCompact">
>                 </wicket:container>
>             </div>
>
>             <wicket:fragment wicket:id="text">
>                 <input type="text" name="scalarValue" class="form-control
> input-sm scalarValue" wicket:id="scalarValue" />
>             </wicket:fragment>
>
>             <wicket:fragment wicket:id="compactAsSpan">
>                 <a wicket:id="externalSite"></a>
>             </wicket:fragment>
>                 </wicket:panel>
>     </body>
> </html>
>
>
> Finally, the factory. This is a horrible hack.
> Basically, I check for any string property that starts with "url".
> Ideally this should be an annotation or something, but I could not figure
> out how to pick up annotations from the property in the "aapliesTo" method
> of the factory:
>
>
> public class UrlPanelFactory extends ComponentFactoryScalarAbstract {
>
>     private static final long serialVersionUID = 1L;
>
>     public UrlPanelFactory() {
>         super(String.class);
>     }
>
>     @Override
>     public ApplicationAdvice appliesTo(IModel<?> model) {
>         if (!(model instanceof ScalarModel)) {
>             return ApplicationAdvice.DOES_NOT_APPLY;
>         }
>
>         ScalarModel scalarModel = (ScalarModel) model;
>         PropertyMemento memento = scalarModel.getPropertyMemento();
>         if (memento != null){
>                 String identifier = memento.getIdentifier();
>                 final ApplicationAdvice appliesIf =
> appliesIf(identifier.startsWith("url"));
>                         return appliesIf;
>         }
>         return ApplicationAdvice.DOES_NOT_APPLY;
>     }
>
>
>     @Override
>     public Component createComponent(final String id, final ScalarModel
> scalarModel) {
>         return new UrlPanel(id, scalarModel);
>     }
>
>     protected SpecificationLoader getSpecificationLoader() {
>         return IsisContext.getSessionFactory().getSpecificationLoader();
>     }
> }
>
>
>
>
> On Sat, August 20, 2016 13:08, Martin Grigorov wrote:
> > Hi Kevin,
> >
> >
> >
> > On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za> wrote:
> >
> >
> >> Hi Alexander,
> >>
> >>
> >> I thought the trick here was to register a new ScalarPanelAbstract that
> >>  would pick up the URL and render it as a click-able link.
> >>
> >> In my testing, I have been able to register my
> >> "isis.example.UrlPanelFactory", which is just a String renderer (copied
> >> from ShortPanel).
> >>
> >> However, I have reached my limit. I can parse the text value, detect
> >> that it is a URL, but now I can't figure out how to create the matching
> >> Wicket
> >> HTML and Java to populate a hyperlink!
> >>
> >>
> >> I was experimenting with the HTML:
> >>
> >>
> >> <wicket:panel>
> >> <div class="shortPanel
> >> scalarNameAndValueComponentType"> <label for="scalarValue"
> >> wicket:id="scalarIfRegular">
> >> <span wicket:id="scalarName"
> >> class="scalarName">[Label text]</span> <span class="scalarValue">
> >> <input type="text"
> >> name="scalarValue" wicket:id="scalarValue" /> <span
> >> wicket:id="feedback"></span>
> >> </span>
> >> </label>
> >> <input type="text"
> >> wicket:id="scalarIfCompact"></input>
> >>
> >>
> >
> > This should not be <input>.
> > "scalarIfCompact" is used for the "view" mode, "scalarIfRegular" for the
> > "edit" mode.
> > I.e. in edit mode you have to use <input> to change the url, in view mode
> > you have to use <a> to be able to click it.
> >
> >
> >> <!--
> >> <span wicket:id="scalarUrl">
> >> <a href='a'
> >> wicket:id="scalarUrl"><input type="text"
> >> wicket:id="scalarUrl"></input></a>
> >>
> >>
> >
> > Remove <input> here too.
> >
> >
> >
> >> </span>
> >> -->
> >> </div>
> >> </wicket:panel>
> >>
> >>
> >> But I don't know how to update the Java:
> >> public class UrlPanel extends ScalarPanelAbstract { ...
> >> // How to manipulate the Wicket component, once I have my URL-containing
> >>  string.
> >>
> >
> > You need to extend #getLabelForCompact() and #getComponentForRegular() (
> > https://github.com/apache/isis/blob/501e890f90d535df43d73a90
> e14295fadc9f9b
> > 64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewe
> r/wicket/ui/c
> > omponents/scalars/ScalarPanelAbstract.java#L171-L177 )
> > For the link (<a wicket:id="scalarUrl">) you can use Wicket's
> ExternalLink
> >  component. For <span wicket:id="scalarUrl"> use WebMarkupContainer, if
> > you really need it to be Wicket component. Otherwise just remove
> wicket:id
> > from it.
> >
> > Try it and let me know if you face any problems!
> >
> >
> >> ...
> >> }
> >>
> >>
> >>
> >> Maybe someone with better Wicket foo can provide some advice...
> >>
> >>
> >> Cheers,
> >> Kevin
> >>
> >>
> >>
> >> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
> >>
> >>>
> >>
> >>>>>
> >>>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
> >>>>>> <ze...@prime-research.com> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> Hi Everyone,
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> I have a (hopefully) simple problem.
> >>>>>> A domain entity has a URL as property - I'm searching for a way
> >>>>>> too make those URLs clickable when displayed in a collection.
> >>>>>>
> >>>>>> For example:
> >>>>>> I want to list a subset of those entitys and from there I want
> >>>>>> the possibility to click the link and get redirected.
> >>>>>>
> >>>>>> Returning a URL from an action works (but only for http(s)
> >>>>>> URLs,
> >>>>>> not for file://), but thats not what I want.
> >>>>>>
> >>>>>> The only solution I see (so far), is too create a seperate
> >>>>>> wicket page with mountPage().
> >>>>>>
> >>>>>> It would also be okay too just have the name of the object and
> >>>>>> if I click it, I get redirected immediatly.
> >>>>>>
> >>>>>>
> >>>>>> I'm up for any suggestions.
> >>>>>>
>
>
>

Re: URLs as property.

Posted by Kevin Meyer <ke...@kmz.co.za>.
Hi Alexander,

If I understand you correctly, I have a solution that could work.

When viewed as an item (by iteself), the URL is just a plain string that
can be edited.

When viewed in a collection, the URLs are rendered as links (but for some
reason my Firefox does not actually respond when I click on the URL, but
all the mark-up seems OK).

See bottom for the Factory, which must be added to
META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory
e.g. mine is:
isis.example.UrlPanelFactory

Hi Martin,

With the following Java:
/**
 * Panel for rendering strings as links.
 */
public class UrlPanel extends ScalarPanelTextFieldParseableAbstract {
    private static final long serialVersionUID = 1L;
    private static final String ID_LINK = "externalSite";


    public UrlPanel(final String id, final ScalarModel scalarModel) {
        super(id, ID_SCALAR_VALUE, scalarModel);
    }

    @Override
    protected IModel<String> getScalarPanelType() {
        return Model.of("stringPanel");
    }

    @Override
    protected Component addComponentForCompact() {
    	System.out.println("addComponentForCompact()");
        Fragment compactFragment = getCompactFragment(CompactType.SPAN);
        final String objectAsString = getModel().getObjectAsString();
        final ExternalLink link = new ExternalLink(ID_LINK,
objectAsString, objectAsString);
    	compactFragment.add(link);
        scalarTypeContainer.addOrReplace(compactFragment);
        return link;
    }
}


I found that I had to overload most of the ScalarPanelAbstract.html and
the ScalarPanelTextFieldAbstract.html to create:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:wicket="http://wicket.apache.org"
      xml:lang="en"
      lang="en">
    <body>
 		<wicket:panel>
            <div class="scalarNameAndValueComponentType"
wicket:id="scalarTypeContainer">
                <div class="form-group" wicket:id="scalarIfRegular">
                    <label wicket:id="scalarName" class="scalarName
control-label">[Label text]</label>
                    <span class="scalarValueWrapper">
                        <div class="scalarPlaceholder">
                            <span class="scalarValueInput">
                                <span class="editing">
                                    <wicket:child/>
										<wicket:container wicket:id="scalarValueContainer"/>
                                    <a wicket:id="editProperty" href="#"
class="edit fa fa-pencil-square-o"/>
                                </span>
                            </span>
                            <span wicket:id="associatedActionLinksRight"
class="associatedActionLinksRight">[drop
down]</span>
                        </div>
                        <span wicket:id="feedback" class="help-block"></span>
                        <span wicket:id="associatedActionLinksBelow"></span>
                    </span>
                    <div class="clearfix"/>
                </div>
                <wicket:container wicket:id="scalarIfCompact">
                </wicket:container>
            </div>

            <wicket:fragment wicket:id="text">
                <input type="text" name="scalarValue" class="form-control
input-sm scalarValue" wicket:id="scalarValue" />
            </wicket:fragment>

            <wicket:fragment wicket:id="compactAsSpan">
                <a wicket:id="externalSite"></a>
            </wicket:fragment>
 		</wicket:panel>
    </body>
</html>


Finally, the factory. This is a horrible hack.
Basically, I check for any string property that starts with "url".
Ideally this should be an annotation or something, but I could not figure
out how to pick up annotations from the property in the "aapliesTo" method
of the factory:


public class UrlPanelFactory extends ComponentFactoryScalarAbstract {

    private static final long serialVersionUID = 1L;

    public UrlPanelFactory() {
        super(String.class);
    }

    @Override
    public ApplicationAdvice appliesTo(IModel<?> model) {
        if (!(model instanceof ScalarModel)) {
            return ApplicationAdvice.DOES_NOT_APPLY;
        }

        ScalarModel scalarModel = (ScalarModel) model;
        PropertyMemento memento = scalarModel.getPropertyMemento();
        if (memento != null){
	        String identifier = memento.getIdentifier();
	        final ApplicationAdvice appliesIf =
appliesIf(identifier.startsWith("url"));
			return appliesIf;
        }
        return ApplicationAdvice.DOES_NOT_APPLY;
    }


    @Override
    public Component createComponent(final String id, final ScalarModel
scalarModel) {
        return new UrlPanel(id, scalarModel);
    }

    protected SpecificationLoader getSpecificationLoader() {
        return IsisContext.getSessionFactory().getSpecificationLoader();
    }
}




On Sat, August 20, 2016 13:08, Martin Grigorov wrote:
> Hi Kevin,
>
>
>
> On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za> wrote:
>
>
>> Hi Alexander,
>>
>>
>> I thought the trick here was to register a new ScalarPanelAbstract that
>>  would pick up the URL and render it as a click-able link.
>>
>> In my testing, I have been able to register my
>> "isis.example.UrlPanelFactory", which is just a String renderer (copied
>> from ShortPanel).
>>
>> However, I have reached my limit. I can parse the text value, detect
>> that it is a URL, but now I can't figure out how to create the matching
>> Wicket
>> HTML and Java to populate a hyperlink!
>>
>>
>> I was experimenting with the HTML:
>>
>>
>> <wicket:panel>
>> <div class="shortPanel
>> scalarNameAndValueComponentType"> <label for="scalarValue"
>> wicket:id="scalarIfRegular">
>> <span wicket:id="scalarName"
>> class="scalarName">[Label text]</span> <span class="scalarValue">
>> <input type="text"
>> name="scalarValue" wicket:id="scalarValue" /> <span
>> wicket:id="feedback"></span>
>> </span>
>> </label>
>> <input type="text"
>> wicket:id="scalarIfCompact"></input>
>>
>>
>
> This should not be <input>.
> "scalarIfCompact" is used for the "view" mode, "scalarIfRegular" for the
> "edit" mode.
> I.e. in edit mode you have to use <input> to change the url, in view mode
> you have to use <a> to be able to click it.
>
>
>> <!--
>> <span wicket:id="scalarUrl">
>> <a href='a'
>> wicket:id="scalarUrl"><input type="text"
>> wicket:id="scalarUrl"></input></a>
>>
>>
>
> Remove <input> here too.
>
>
>
>> </span>
>> -->
>> </div>
>> </wicket:panel>
>>
>>
>> But I don't know how to update the Java:
>> public class UrlPanel extends ScalarPanelAbstract { ...
>> // How to manipulate the Wicket component, once I have my URL-containing
>>  string.
>>
>
> You need to extend #getLabelForCompact() and #getComponentForRegular() (
> https://github.com/apache/isis/blob/501e890f90d535df43d73a90e14295fadc9f9b
> 64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/c
> omponents/scalars/ScalarPanelAbstract.java#L171-L177 )
> For the link (<a wicket:id="scalarUrl">) you can use Wicket's ExternalLink
>  component. For <span wicket:id="scalarUrl"> use WebMarkupContainer, if
> you really need it to be Wicket component. Otherwise just remove wicket:id
> from it.
>
> Try it and let me know if you face any problems!
>
>
>> ...
>> }
>>
>>
>>
>> Maybe someone with better Wicket foo can provide some advice...
>>
>>
>> Cheers,
>> Kevin
>>
>>
>>
>> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
>>
>>>
>>
>>>>>
>>>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
>>>>>> <ze...@prime-research.com> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi Everyone,
>>>>>>
>>>>>>
>>>>>>
>>>>>> I have a (hopefully) simple problem.
>>>>>> A domain entity has a URL as property - I'm searching for a way
>>>>>> too make those URLs clickable when displayed in a collection.
>>>>>>
>>>>>> For example:
>>>>>> I want to list a subset of those entitys and from there I want
>>>>>> the possibility to click the link and get redirected.
>>>>>>
>>>>>> Returning a URL from an action works (but only for http(s)
>>>>>> URLs,
>>>>>> not for file://), but thats not what I want.
>>>>>>
>>>>>> The only solution I see (so far), is too create a seperate
>>>>>> wicket page with mountPage().
>>>>>>
>>>>>> It would also be okay too just have the name of the object and
>>>>>> if I click it, I get redirected immediatly.
>>>>>>
>>>>>>
>>>>>> I'm up for any suggestions.
>>>>>>



Re: URLs as property.

Posted by Martin Grigorov <mg...@apache.org>.
Hi Kevin,


On Fri, Aug 19, 2016 at 11:14 PM, Kevin Meyer <ke...@kmz.co.za> wrote:

> Hi Alexander,
>
> I thought the trick here was to register a new ScalarPanelAbstract that
> would pick up the URL and render it as a click-able link.
>
> In my testing, I have been able to register my
> "isis.example.UrlPanelFactory", which is just a String renderer (copied
> from ShortPanel).
>
> However, I have reached my limit. I can parse the text value, detect that
> it is a URL, but now I can't figure out how to create the matching Wicket
> HTML and Java to populate a hyperlink!
>
> I was experimenting with the HTML:
>
>                 <wicket:panel>
>                         <div class="shortPanel
> scalarNameAndValueComponentType">
>                                 <label for="scalarValue"
> wicket:id="scalarIfRegular">
>                                 <span wicket:id="scalarName"
> class="scalarName">[Label text]</span>
>                                 <span class="scalarValue">
>                                         <input type="text"
> name="scalarValue" wicket:id="scalarValue" />
>                                         <span wicket:id="feedback"></span>
>                                 </span>
>                                 </label>
>                                 <input type="text"
> wicket:id="scalarIfCompact"></input>
>

This should not be <input>.
"scalarIfCompact" is used for the "view" mode, "scalarIfRegular" for the
"edit" mode.
I.e. in edit mode you have to use <input> to change the url, in view mode
you have to use <a> to be able to click it.


> <!--
>                         <span wicket:id="scalarUrl">
>                                         <a href='a'
> wicket:id="scalarUrl"><input type="text"
> wicket:id="scalarUrl"></input></a>
>

Remove <input> here too.


>                                 </span>
> -->
>                         </div>
>                 </wicket:panel>
>
> But I don't know how to update the Java:
> public class UrlPanel extends ScalarPanelAbstract {
> ...
> // How to manipulate the Wicket component, once I have my URL-containing
> string.
>

You need to extend #getLabelForCompact() and #getComponentForRegular() (
https://github.com/apache/isis/blob/501e890f90d535df43d73a90e14295fadc9f9b64/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java#L171-L177
)
For the link (<a wicket:id="scalarUrl">) you can use Wicket's ExternalLink
component.
For <span wicket:id="scalarUrl"> use WebMarkupContainer, if you really need
it to be Wicket component. Otherwise just remove wicket:id from it.

Try it and let me know if you face any problems!

> ...
> }
>
>
> Maybe someone with better Wicket foo can provide some advice...
>
> Cheers,
> Kevin
>
>
> On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
> >
>
> > Hellp Joerg,
> >
> >
> > thanks for  the reply, but  like I said: Creation of a action, that
> > returns a URL and therefore executes a redirect is not a problem.
> >
> > Maybe I should make a feature request for wicked out of my question.
> >
> >
> > "Please render properties of type URL (Java.lang) as clickable links."
> >
> >
> > I was just looking for a possible solution for that case. :-)
> >
> >
> > Best regards
> >
> >
> > Rade, Joerg / Kuehne + Nagel / Ham GI-DP <Jo...@Kuehne-Nagel.com>
> > writes:
> >
> >
> >> Hi Alexander,
> >>
> >>
> >> I use the following:
> >>
> >>
> >> @ActionLayout(cssClassFa = "spinner")
> >> public URL openURL(final RuntimeEnvironment rte) throws
> >> MalformedURLException {
> >> URL url = null;
> >> try { url = new URL(rte.getUri()); } catch (Exception e) {
> >> messageService.raiseError("URL could not be opened"); }
> >> return url; }
> >>
> >>
> >> where RuntimeEnvironment#getUri() is:
> >>
> >> public String getUri() { return "http://" + getHost().title() + ":" +
> >> getPort() + getPath(); }
> >>
> >>
> >> So the URL is not a property - it's constructed from strings.
> >>
> >>
> >> HTH -j
> >> -----Ursprüngliche Nachricht-----
> >> Von: Alexander Zerbe [mailto:zerbe@prime-research.com]
> >> Gesendet: Donnerstag, 18. August 2016 11:51
> >> An: users@isis.apache.org
> >> Betreff: Re: URLs as property.
> >>
> >>
> >>
> >> Hello Sander,
> >>
> >>
> >> thanks for your reply, but no that was not what I ment. I have a domain
> >> entity that has a URL as a property (where it is accessible/stored or
> >> where it 'lives').
> >>
> >> I'm searching for the best way to make this URL accessible (clickable).
> >>
> >>
> >> For example - I want to display all entities and I only want their name
> >> and URL, but the URL gets rendered as a string. So you must copy this
> >> string, open a new browser tab, insert it and open the URL by hand.
> >>
> >> In the future I will just create a frontend for this, but right now I
> >> would like to know if its possible to render every string that begins
> >> with 'http(s)' as a link.
> >>
> >> Best regards.
> >>
> >>
> >> Sander Ginn <sa...@ginn.it> writes:
> >>
> >>
> >>> Hi Alexander,
> >>>
> >>>
> >>> I'm not completely sure if I understand your question correctly, but
> >>> I think this is the answer:
> >>> Each item in a collection has an icon associated with it in the
> >>> leftmost column of the table. This icon is clickable and will
> >>> redirect you to the specific object. An example with the icon marked
> >>> with a red circle is attached.
> >>>
> >>> Kind regards,
> >>> Sander Ginn
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
> >>>> <ze...@prime-research.com> wrote:
> >>>>
> >>>>
> >>>> Hi Everyone,
> >>>>
> >>>>
> >>>> I have a (hopefully) simple problem.
> >>>> A domain entity has a URL as property - I'm searching for a way too
> >>>> make those URLs clickable when displayed in a collection.
> >>>>
> >>>> For example:
> >>>> I want to list a subset of those entitys and from there I want the
> >>>> possibility to click the link and get redirected.
> >>>>
> >>>> Returning a URL from an action works (but only for http(s) URLs,
> >>>> not for file://), but thats not what I want.
> >>>>
> >>>> The only solution I see (so far), is too create a seperate wicket
> >>>> page with mountPage().
> >>>>
> >>>> It would also be okay too just have the name of the object and if I
> >>>>  click it, I get redirected immediatly.
> >>>>
> >>>>
> >>>> I'm up for any suggestions.
> >>>>
> >>>>
> >>>>
> >>>> Best regards
> >>>>
> >>
> >>
> >> Kühne + Nagel (AG & Co.) KG
> >> Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE
> >> 812773878.
> >> Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Yngve Ruud (Vors.), Martin
> >> Brinkmann, Matthias Heimbach, Jan-Hendrik Köstergarten, Nicholas Minde,
> >> Michael Nebel, Lars Wedel.
> >> Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform:
> >> Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745,
> >> Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
> >> Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Diederick de
> >> Vroet, Dominic Edmonds, Thierry Held, Uwe Hött, Richard Huhn, Björn
> >> Johansson, Holger Ketz, Jan Kunze.
> >>
> >>
> >> Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen
> >> Spediteurbedingungen 2016 (ADSp 2016). Die ADSp 2016 beschränken in
> >> Ziffer 23 die gesetzliche Haftung für Güterschäden in Höhe von 8,33
> >> SZR/kg je Schadenfall bzw. je Schadenereignis auf 1 Million bzw. 2
> >> Millionen Euro oder 2 SZR/kg, je nachdem, welcher Betrag höher ist, und
> >> bei multimodalen Transporten unter Einschluss einer Seebeförderung
> >> generell auf 2 SZR/kg. Den vollständigen Text der ADSp 2016 übersenden
> >> wir Ihnen gerne auf Anfrage und können Sie auch unter
> >> http://www.kuehne-nagel.com einsehen.
> >>
> >
> >
>
>
>

Re: URLs as property.

Posted by Kevin Meyer <ke...@kmz.co.za>.
Hi Alexander,

I thought the trick here was to register a new ScalarPanelAbstract that
would pick up the URL and render it as a click-able link.

In my testing, I have been able to register my
"isis.example.UrlPanelFactory", which is just a String renderer (copied
from ShortPanel).

However, I have reached my limit. I can parse the text value, detect that
it is a URL, but now I can't figure out how to create the matching Wicket
HTML and Java to populate a hyperlink!

I was experimenting with the HTML:

		<wicket:panel>
			<div class="shortPanel scalarNameAndValueComponentType">
				<label for="scalarValue" wicket:id="scalarIfRegular">
	      			<span wicket:id="scalarName" class="scalarName">[Label text]</span>
	      			<span class="scalarValue">
	      				<input type="text" name="scalarValue" wicket:id="scalarValue" />
		      			<span wicket:id="feedback"></span>
	      			</span>
				</label>
				<input type="text" wicket:id="scalarIfCompact"></input>
<!--
      			<span wicket:id="scalarUrl">
					<a href='a' wicket:id="scalarUrl"><input type="text"
wicket:id="scalarUrl"></input></a>
				</span>
-->
			</div>
		</wicket:panel>

But I don't know how to update the Java:
public class UrlPanel extends ScalarPanelAbstract {
...
// How to manipulate the Wicket component, once I have my URL-containing
string.
...
}


Maybe someone with better Wicket foo can provide some advice...

Cheers,
Kevin


On Fri, August 19, 2016 17:35, Alexander Zerbe wrote:
>

> Hellp Joerg,
>
>
> thanks for  the reply, but  like I said: Creation of a action, that
> returns a URL and therefore executes a redirect is not a problem.
>
> Maybe I should make a feature request for wicked out of my question.
>
>
> "Please render properties of type URL (Java.lang) as clickable links."
>
>
> I was just looking for a possible solution for that case. :-)
>
>
> Best regards
>
>
> Rade, Joerg / Kuehne + Nagel / Ham GI-DP <Jo...@Kuehne-Nagel.com>
> writes:
>
>
>> Hi Alexander,
>>
>>
>> I use the following:
>>
>>
>> @ActionLayout(cssClassFa = "spinner")
>> public URL openURL(final RuntimeEnvironment rte) throws
>> MalformedURLException {
>> URL url = null;
>> try { url = new URL(rte.getUri()); } catch (Exception e) {
>> messageService.raiseError("URL could not be opened"); }
>> return url; }
>>
>>
>> where RuntimeEnvironment#getUri() is:
>>
>> public String getUri() { return "http://" + getHost().title() + ":" +
>> getPort() + getPath(); }
>>
>>
>> So the URL is not a property - it's constructed from strings.
>>
>>
>> HTH -j
>> -----Urspr�ngliche Nachricht-----
>> Von: Alexander Zerbe [mailto:zerbe@prime-research.com]
>> Gesendet: Donnerstag, 18. August 2016 11:51
>> An: users@isis.apache.org
>> Betreff: Re: URLs as property.
>>
>>
>>
>> Hello Sander,
>>
>>
>> thanks for your reply, but no that was not what I ment. I have a domain
>> entity that has a URL as a property (where it is accessible/stored or
>> where it 'lives').
>>
>> I'm searching for the best way to make this URL accessible (clickable).
>>
>>
>> For example - I want to display all entities and I only want their name
>> and URL, but the URL gets rendered as a string. So you must copy this
>> string, open a new browser tab, insert it and open the URL by hand.
>>
>> In the future I will just create a frontend for this, but right now I
>> would like to know if its possible to render every string that begins
>> with 'http(s)' as a link.
>>
>> Best regards.
>>
>>
>> Sander Ginn <sa...@ginn.it> writes:
>>
>>
>>> Hi Alexander,
>>>
>>>
>>> I'm not completely sure if I understand your question correctly, but
>>> I think this is the answer:
>>> Each item in a collection has an icon associated with it in the
>>> leftmost column of the table. This icon is clickable and will
>>> redirect you to the specific object. An example with the icon marked
>>> with a red circle is attached.
>>>
>>> Kind regards,
>>> Sander Ginn
>>>
>>>
>>>
>>>
>>>
>>>> On 12 Aug 2016, at 11:56, Alexander Zerbe
>>>> <ze...@prime-research.com> wrote:
>>>>
>>>>
>>>> Hi Everyone,
>>>>
>>>>
>>>> I have a (hopefully) simple problem.
>>>> A domain entity has a URL as property - I'm searching for a way too
>>>> make those URLs clickable when displayed in a collection.
>>>>
>>>> For example:
>>>> I want to list a subset of those entitys and from there I want the
>>>> possibility to click the link and get redirected.
>>>>
>>>> Returning a URL from an action works (but only for http(s) URLs,
>>>> not for file://), but thats not what I want.
>>>>
>>>> The only solution I see (so far), is too create a seperate wicket
>>>> page with mountPage().
>>>>
>>>> It would also be okay too just have the name of the object and if I
>>>>  click it, I get redirected immediatly.
>>>>
>>>>
>>>> I'm up for any suggestions.
>>>>
>>>>
>>>>
>>>> Best regards
>>>>
>>
>>
>> K�hne + Nagel (AG & Co.) KG
>> Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE
>> 812773878.
>> Gesch�ftsleitung K�hne + Nagel (AG & Co.) KG: Yngve Ruud (Vors.), Martin
>> Brinkmann, Matthias Heimbach, Jan-Hendrik K�stergarten, Nicholas Minde,
>> Michael Nebel, Lars Wedel.
>> Pers�nlich haftende Gesellschafterin: K�hne & Nagel A.G., Rechtsform:
>> Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745,
>> Gesch�ftsf�hrendes Verwaltungsratsmitglied: Karl Gernandt.
>> Gesch�ftsleitung Region Westeuropa: Yngve Ruud (Vors.), Diederick de
>> Vroet, Dominic Edmonds, Thierry Held, Uwe H�tt, Richard Huhn, Bj�rn
>> Johansson, Holger Ketz, Jan Kunze.
>>
>>
>> Wir arbeiten ausschlie�lich auf Grundlage der Allgemeinen Deutschen
>> Spediteurbedingungen 2016 (ADSp 2016). Die ADSp 2016 beschr�nken in
>> Ziffer 23 die gesetzliche Haftung f�r G�tersch�den in H�he von 8,33
>> SZR/kg je Schadenfall bzw. je Schadenereignis auf 1 Million bzw. 2
>> Millionen Euro oder 2 SZR/kg, je nachdem, welcher Betrag h�her ist, und
>> bei multimodalen Transporten unter Einschluss einer Seebef�rderung
>> generell auf 2 SZR/kg. Den vollst�ndigen Text der ADSp 2016 �bersenden
>> wir Ihnen gerne auf Anfrage und k�nnen Sie auch unter
>> http://www.kuehne-nagel.com einsehen.
>>
>
>



Re: AW: URLs as property.

Posted by Alexander Zerbe <ze...@prime-research.com>.
Hellp Joerg,

thanks for  the reply, but  like I said:
Creation of a action, that returns a URL and therefore executes a
redirect is not a problem.

Maybe I should make a feature request for wicked out of my question.

"Please render properties of type URL (Java.lang) as clickable links."

I was just looking for a possible solution for that case. :-)

Best regards

Rade, Joerg / Kuehne + Nagel / Ham GI-DP <Jo...@Kuehne-Nagel.com> writes:

> Hi Alexander,
>
> I use the following:
>
>         @ActionLayout(cssClassFa = "spinner")
>         public URL openURL(final RuntimeEnvironment rte) throws MalformedURLException {
>                 URL url = null;
>                 try {
>                         url = new URL(rte.getUri());
>                 } catch (Exception e) {
>                         messageService.raiseError("URL could not be opened");
>                 }
>                 return url;
>         }
>
> where RuntimeEnvironment#getUri() is:
>
>         public String getUri() {
>                 return "http://" + getHost().title() + ":" + getPort() + getPath();
>         }
>
> So the URL is not a property - it's constructed from strings.
>
> HTH -j
> -----Urspr�ngliche Nachricht-----
> Von: Alexander Zerbe [mailto:zerbe@prime-research.com]
> Gesendet: Donnerstag, 18. August 2016 11:51
> An: users@isis.apache.org
> Betreff: Re: URLs as property.
>
>
> Hello Sander,
>
> thanks for your reply, but no that was not what I ment.
> I have a domain entity that has a URL as a property (where it is accessible/stored or where it 'lives').
>
> I'm searching for the best way to make this URL accessible (clickable).
>
> For example - I want to display all entities and I only want their name and URL, but the URL gets rendered as a string.
> So you must copy this string, open a new browser tab, insert it and open the URL by hand.
>
> In the future I will just create a frontend for this, but right now I would like to know if its possible to render every string that begins with 'http(s)' as a link.
>
> Best regards.
>
> Sander Ginn <sa...@ginn.it> writes:
>
>> Hi Alexander,
>>
>> I'm not completely sure if I understand your question correctly, but I think this is the answer:
>> Each item in a collection has an icon associated with it in the leftmost column of the table. This icon is clickable and will redirect you to the specific object. An example with the icon marked with a red circle is attached.
>>
>> Kind regards,
>> Sander Ginn
>>
>>
>>
>>
>>> On 12 Aug 2016, at 11:56, Alexander Zerbe <ze...@prime-research.com> wrote:
>>>
>>> Hi Everyone,
>>>
>>> I have a (hopefully) simple problem.
>>> A domain entity has a URL as property - I'm searching for a way too
>>> make those URLs clickable when displayed in a collection.
>>>
>>> For example:
>>> I want to list a subset of those entitys and from there I want the
>>> possibility to click the link and get redirected.
>>>
>>> Returning a URL from an action works (but only for http(s) URLs, not
>>> for file://), but thats not what I want.
>>>
>>> The only solution I see (so far), is too create a seperate wicket
>>> page with mountPage().
>>>
>>> It would also be okay too just have the name of the object and if I
>>> click it, I get redirected immediatly.
>>>
>>>
>>> I'm up for any suggestions.
>>>
>>>
>>> Best regards
>
>
> K�hne + Nagel (AG & Co.) KG
> Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
> Gesch�ftsleitung K�hne + Nagel (AG & Co.) KG: Yngve Ruud (Vors.), Martin Brinkmann, Matthias Heimbach, Jan-Hendrik K�stergarten, Nicholas Minde, Michael Nebel, Lars Wedel.
> Pers�nlich haftende Gesellschafterin: K�hne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Gesch�ftsf�hrendes Verwaltungsratsmitglied: Karl Gernandt.
> Gesch�ftsleitung Region Westeuropa: Yngve Ruud (Vors.), Diederick de Vroet, Dominic Edmonds, Thierry Held, Uwe H�tt, Richard Huhn, Bj�rn Johansson, Holger Ketz, Jan Kunze.
>
> Wir arbeiten ausschlie�lich auf Grundlage der Allgemeinen Deutschen Spediteurbedingungen 2016 (ADSp 2016). Die ADSp 2016 beschr�nken in Ziffer 23 die gesetzliche Haftung f�r G�tersch�den in H�he von 8,33 SZR/kg je Schadenfall bzw. je Schadenereignis auf 1 Million bzw. 2 Millionen Euro oder 2 SZR/kg, je nachdem, welcher Betrag h�her ist, und bei multimodalen Transporten unter Einschluss einer Seebef�rderung generell auf 2 SZR/kg. Den vollst�ndigen Text der ADSp 2016 �bersenden wir Ihnen gerne auf Anfrage und k�nnen Sie auch unter http://www.kuehne-nagel.com einsehen.


AW: URLs as property.

Posted by "Rade, Joerg / Kuehne + Nagel / Ham GI-DP" <Jo...@Kuehne-Nagel.com>.
Hi Alexander,

I use the following:

        @ActionLayout(cssClassFa = "spinner")
        public URL openURL(final RuntimeEnvironment rte) throws MalformedURLException {
                URL url = null;
                try {
                        url = new URL(rte.getUri());
                } catch (Exception e) {
                        messageService.raiseError("URL could not be opened");
                }
                return url;
        }

where RuntimeEnvironment#getUri() is:

        public String getUri() {
                return "http://" + getHost().title() + ":" + getPort() + getPath();
        }

So the URL is not a property - it's constructed from strings.

HTH -j
-----Ursprüngliche Nachricht-----
Von: Alexander Zerbe [mailto:zerbe@prime-research.com]
Gesendet: Donnerstag, 18. August 2016 11:51
An: users@isis.apache.org
Betreff: Re: URLs as property.


Hello Sander,

thanks for your reply, but no that was not what I ment.
I have a domain entity that has a URL as a property (where it is accessible/stored or where it 'lives').

I'm searching for the best way to make this URL accessible (clickable).

For example - I want to display all entities and I only want their name and URL, but the URL gets rendered as a string.
So you must copy this string, open a new browser tab, insert it and open the URL by hand.

In the future I will just create a frontend for this, but right now I would like to know if its possible to render every string that begins with 'http(s)' as a link.

Best regards.

Sander Ginn <sa...@ginn.it> writes:

> Hi Alexander,
>
> I'm not completely sure if I understand your question correctly, but I think this is the answer:
> Each item in a collection has an icon associated with it in the leftmost column of the table. This icon is clickable and will redirect you to the specific object. An example with the icon marked with a red circle is attached.
>
> Kind regards,
> Sander Ginn
>
>
>
>
>> On 12 Aug 2016, at 11:56, Alexander Zerbe <ze...@prime-research.com> wrote:
>>
>> Hi Everyone,
>>
>> I have a (hopefully) simple problem.
>> A domain entity has a URL as property - I'm searching for a way too
>> make those URLs clickable when displayed in a collection.
>>
>> For example:
>> I want to list a subset of those entitys and from there I want the
>> possibility to click the link and get redirected.
>>
>> Returning a URL from an action works (but only for http(s) URLs, not
>> for file://), but thats not what I want.
>>
>> The only solution I see (so far), is too create a seperate wicket
>> page with mountPage().
>>
>> It would also be okay too just have the name of the object and if I
>> click it, I get redirected immediatly.
>>
>>
>> I'm up for any suggestions.
>>
>>
>> Best regards


Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Yngve Ruud (Vors.), Martin Brinkmann, Matthias Heimbach, Jan-Hendrik Köstergarten, Nicholas Minde, Michael Nebel, Lars Wedel.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Diederick de Vroet, Dominic Edmonds, Thierry Held, Uwe Hött, Richard Huhn, Björn Johansson, Holger Ketz, Jan Kunze.

Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteurbedingungen 2016 (ADSp 2016). Die ADSp 2016 beschränken in Ziffer 23 die gesetzliche Haftung für Güterschäden in Höhe von 8,33 SZR/kg je Schadenfall bzw. je Schadenereignis auf 1 Million bzw. 2 Millionen Euro oder 2 SZR/kg, je nachdem, welcher Betrag höher ist, und bei multimodalen Transporten unter Einschluss einer Seebeförderung generell auf 2 SZR/kg. Den vollständigen Text der ADSp 2016 übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen.

Re: URLs as property.

Posted by Alexander Zerbe <ze...@prime-research.com>.
Hello Sander,

thanks for your reply, but no that was not what I ment.
I have a domain entity that has a URL as a property (where it is
accessible/stored or where it 'lives').

I'm searching for the best way to make this URL accessible (clickable).

For example - I want to display all entities and I only
want their name and URL, but the URL gets rendered as a string.
So you must copy this string, open a new browser tab, insert it and open
the URL by hand.

In the future I will just create a frontend for this, but right now I
would like to know if its possible to render every string that begins
with 'http(s)' as a link.

Best regards.

Sander Ginn <sa...@ginn.it> writes:

> Hi Alexander,
>
> I'm not completely sure if I understand your question correctly, but I think this is the answer:
> Each item in a collection has an icon associated with it in the leftmost column of the table. This icon is clickable and will redirect you to the specific object. An example with the icon marked with a red circle is attached.
>
> Kind regards,
> Sander Ginn
>
>
>
>
>> On 12 Aug 2016, at 11:56, Alexander Zerbe <ze...@prime-research.com> wrote:
>> 
>> Hi Everyone,
>> 
>> I have a (hopefully) simple problem. 
>> A domain entity has a URL as property - I'm searching for a way too
>> make those URLs clickable when displayed in a collection.
>> 
>> For example:
>> I want to list a subset of those entitys and from there I want the 
>> possibility to click the link and get redirected.
>> 
>> Returning a URL from an action works (but only for http(s) URLs, not
>> for file://), but thats not what I want. 
>> 
>> The only solution I see (so far), is too create a seperate wicket page
>> with mountPage().
>> 
>> It would also be okay too just have the name of the object and if I
>> click it, I get redirected immediatly.
>> 
>> 
>> I'm up for any suggestions.
>> 
>> 
>> Best regards


Re: URLs as property.

Posted by Sander Ginn <sa...@ginn.it>.
Hi Alexander,

I'm not completely sure if I understand your question correctly, but I think this is the answer:
Each item in a collection has an icon associated with it in the leftmost column of the table. This icon is clickable and will redirect you to the specific object. An example with the icon marked with a red circle is attached.

Kind regards,
Sander Ginn




> On 12 Aug 2016, at 11:56, Alexander Zerbe <ze...@prime-research.com> wrote:
> 
> Hi Everyone,
> 
> I have a (hopefully) simple problem. 
> A domain entity has a URL as property - I'm searching for a way too
> make those URLs clickable when displayed in a collection.
> 
> For example:
> I want to list a subset of those entitys and from there I want the 
> possibility to click the link and get redirected.
> 
> Returning a URL from an action works (but only for http(s) URLs, not
> for file://), but thats not what I want. 
> 
> The only solution I see (so far), is too create a seperate wicket page
> with mountPage().
> 
> It would also be okay too just have the name of the object and if I
> click it, I get redirected immediatly.
> 
> 
> I'm up for any suggestions.
> 
> 
> Best regards