Re: Clearing Cache after Logout
Hmm I'd do what you do and set a custom expired page, with perhaps a login form on it.. Voila :) vishy_sb wrote: Hi all, I have a logout link that takes me to the login (Home) page. However when I click the back button it brings me back to the same page that I was on (Although I am not able to do anything on this page as whenever I press some button I get the error Page Expired) A better option would be to display the Log in page itself even if the back button is pressed. I am trying to clear the cache so that the back button becomes disabled whenever the log out button is pressed. The code for my logout button is below: Link logout = new Link(logout){ private static final long serialVersionUID = 1L; @Override public void onClick() { session.invalidate(); getRequestCycle().setRedirect(true); setResponsePage(Index.class); } }; Any ideas how this could be resolved. Thanks in advance, vishy -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
pimping Openlayers in wicket stuff core...
Hi Guys I'll be putting in direct JTS (http://www.vividsolutions.com/jts/main.htm) support in Openlayers contrib. Any objections to this? This means that the API will break, since I'll be using JTS points instead of the homegrown classes as currently. Also I plan to support drawing shapes on screen. If have any input on this please say so.. -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Page indirection
Not sure what do you want and why is it about wicket? Why not just make a redirector service, like: interface IRedirector { void redirect(PageParams pp); } class TournamentRedirector implements IRedirector { void redirect(PageParams pp) { setResponsePage(EditTournament.class, pp); } } class SpecialTournamentRedirector implements IRedirector { void redirect(PageParams pp) { setResponsePage(SpecialEditTournament.class, pp); } } and inject one of these objects? 2008/12/4 Steve Flasby [EMAIL PROTECTED]: Hi, I am looking to add a little more configurability to my Wicket app. At the moment all forward requests are coded something like: setResponsePage( EditTournament.class, pp ); but I would like to be able to configure this more flexibly. For example, for certain installations I may want to forward to a subclass of EditTournament to handle a specialized version of this page with some additional input fields. I was hoping to use Guice for this (I dont like String based config), but it seems to be hard to selectively inject classes: @Inject(optional=true) Class? extends Page mEditTournament = EditTournament.class; ... setResponsePage( mEditTournament, pp ); as this approach requires a coding standard of always injecting Pages as well as there being currently no simple way to selectively inject constants using Guice. I would override setResponse(..) but these are final methods so that route is also closed. I hope what Im trying to do is clear, can anyone offer a solution? Cheers - Steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- WBR, kan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Directions for Stateless Ajax
nate roe wrote: I've written a stateless auto-complete TextField by adapting Wicket's own JavaScript and using a servlet for the back end. I don't like the servlet and I would like to instead use Wicket to serve the auto-complete suggestions list, but I'm not sure how. Well, I've just implemented a StatelessAutoCompleteTextField that works in wicket directly :) I used a similar technique to my StatlessAjaxLink described at http://www.nabble.com/Stateless-AJAX-links-td20031309.html Specifically, I copied AutoCompleteTextField and made some modifications: - replaced the AutoCompleteBehavior with a StatelessAutoCompleteBehavior and stored it in a field - implemented ILinkListener and called the autocomplete behavior's respond method from onLinkClicked StatelessAutoCompleteBehavior extends AutoCompleteBehavior with the following changes: - getStatelessHint returns true - getCallbackUrl returns a url constructed using ILinkListener.INTERFACE - onBind calls getComponent().setOutputMarkupId(true) (just like AbstractDefaultAjaxBehavior) For the record, I'm using wicket 1.4-m3 Adrian -- View this message in context: http://www.nabble.com/Directions-for-Stateless-Ajax-tp17518987p20830784.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Directions for Stateless Ajax
Nino.Martinez wrote: Why not put these to into wicketstuff minies? aditsu wrote: Well, I've just implemented a StatelessAutoCompleteTextField that works in wicket directly :) I used a similar technique to my StatlessAjaxLink described at http://www.nabble.com/Stateless-AJAX-links-td20031309.html First, because I hadn't heard of that; second, I need approval from my boss. I expect he'll be ok. Oh and third, I need time to run some more tests. Adrian -- View this message in context: http://www.nabble.com/Directions-for-Stateless-Ajax-tp17518987p20831648.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: avoid ajax response evaluate javascript
i've been using the aforementioned toggle behavior almost always in ajaxy pages, and in that case they work fine. basically that means i add toggle behaviors to components in a page. when i call an ajax link, toggle works ok because the isTemporary() method of the behavior returns *true* (otherwise it would attach the toggle effect contribution to the header-contribution part of the response and it would blow things up - i.e. triggering more than once a certain toggle effect). however, i now started using that in pages that use normal links (not ajax). so when i get the (non ajax) response for the linked page, as the behavior is temporary, it won't contribute to the header anymore. thus breaking the effect. say page1 links to page1b [a new version of page1] when i diff page1 page1b i roughly get this: 24,28d23 script type=text/javascript src=resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js/script script type=text/javascript !--/*--![CDATA[/*!--*/ Wicket.Event.add(window, domready, function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;}); /*--]]*//script i.e. the toggle effect won't work in page1b because function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;} is not present in that page at all. note this doesn't pose a problem if i refresh certain components via ajax because the original page still contains this javascript listener in the header. my question: is there a way to tell inside isTemporary() whether the request was ajax or normal, to return true or false according to that? other suggestions? francisco On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy [EMAIL PROTECTED] wrote: It did.. You could try the isTemporary (return true) on the behavior, it thanks nino... that *is* the solution, works like a charm my mistake for not paying attention to the last bits of the javadoc ibehavior page :) boolean isTemporary() Specifies whether or not this behavior is temporary. Temporary behaviors are removed at the end of request. Such behaviors are useful for modifying component rendering only when it renders next. Usecases include javascript effects, initial clientside dom setup, etc. ... couldn't be more clear... cheers, francisco On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Hi Francisco It did.. You could try the isTemporary (return true) on the behavior, it could mean that it will only add the behavior for that request, but I am not sure.. Or you could try creating a new markupcontainer (listOfCommentsContainer), it'll give it a new id.. Or you could stuff in some logic as a ajaxcalldecorator on your link, that will clean it up in pure js... I had some difficulties with exactly this when I did the wicket reaction game. I hope this helpes.. francisco treacy wrote: want to not output the list with wicket's ordinary ajax replace method? hmmm... wicket's ordinary ajax replace method? the basic problem here is: -when the page is first rendered, the following is added to the dom (it's the behaviour responsible for this): $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) -when i click on the trigger link (numberOfCommentsLink24) i fire an ajax request, and add a webmarkupcontainer (listOfCommentsContainer25) i want to refresh: target.addComponent(listOfCommentsContainer); -the ajax response is: *not only* the updated listOfCommentsContainer25, but *also* an evaluate section in the ajax response, that includes: $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) (of course, because the behaviour has been added to the listOfCommentsContainer). -... that means, i now have loaded in the dom *twice* : $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) so with *one* click on the numberOfCommentsLink24 , i get *two* calls to $('#listOfCommentsContainer25').slideToggle(450); which basically slides up, and immediately down. that is, slide toggle means it goes up (hides) if it was down (visible), it goes down (shows) if it was up (hidden). i want to avoid this behaviour by stopping the ajax response from spitting back the javascript code for a second time. perhaps do something inside the behaviour class? hope it clarifies! thanks, francisco On Thu, Nov 6, 2008 at 1:53 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Im not sure I understand then..? Could you explain another way? You would want to not output the list with wicket's ordinary ajax replace method? francisco treacy wrote: yes, i'm aware of those. but i'd want to 'remove' things from the ajaxRequestTarget rather than append... or, some way of attaching/executing behaviours only
Re: avoid ajax response evaluate javascript
There is ServletWebRequest.isAjax ** Martin 2008/12/4 francisco treacy [EMAIL PROTECTED]: i've been using the aforementioned toggle behavior almost always in ajaxy pages, and in that case they work fine. basically that means i add toggle behaviors to components in a page. when i call an ajax link, toggle works ok because the isTemporary() method of the behavior returns *true* (otherwise it would attach the toggle effect contribution to the header-contribution part of the response and it would blow things up - i.e. triggering more than once a certain toggle effect). however, i now started using that in pages that use normal links (not ajax). so when i get the (non ajax) response for the linked page, as the behavior is temporary, it won't contribute to the header anymore. thus breaking the effect. say page1 links to page1b [a new version of page1] when i diff page1 page1b i roughly get this: 24,28d23 script type=text/javascript src=resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js/script script type=text/javascript !--/*--![CDATA[/*!--*/ Wicket.Event.add(window, domready, function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;}); /*--]]*//script i.e. the toggle effect won't work in page1b because function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;} is not present in that page at all. note this doesn't pose a problem if i refresh certain components via ajax because the original page still contains this javascript listener in the header. my question: is there a way to tell inside isTemporary() whether the request was ajax or normal, to return true or false according to that? other suggestions? francisco On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy [EMAIL PROTECTED] wrote: It did.. You could try the isTemporary (return true) on the behavior, it thanks nino... that *is* the solution, works like a charm my mistake for not paying attention to the last bits of the javadoc ibehavior page :) boolean isTemporary() Specifies whether or not this behavior is temporary. Temporary behaviors are removed at the end of request. Such behaviors are useful for modifying component rendering only when it renders next. Usecases include javascript effects, initial clientside dom setup, etc. ... couldn't be more clear... cheers, francisco On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Hi Francisco It did.. You could try the isTemporary (return true) on the behavior, it could mean that it will only add the behavior for that request, but I am not sure.. Or you could try creating a new markupcontainer (listOfCommentsContainer), it'll give it a new id.. Or you could stuff in some logic as a ajaxcalldecorator on your link, that will clean it up in pure js... I had some difficulties with exactly this when I did the wicket reaction game. I hope this helpes.. francisco treacy wrote: want to not output the list with wicket's ordinary ajax replace method? hmmm... wicket's ordinary ajax replace method? the basic problem here is: -when the page is first rendered, the following is added to the dom (it's the behaviour responsible for this): $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) -when i click on the trigger link (numberOfCommentsLink24) i fire an ajax request, and add a webmarkupcontainer (listOfCommentsContainer25) i want to refresh: target.addComponent(listOfCommentsContainer); -the ajax response is: *not only* the updated listOfCommentsContainer25, but *also* an evaluate section in the ajax response, that includes: $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) (of course, because the behaviour has been added to the listOfCommentsContainer). -... that means, i now have loaded in the dom *twice* : $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) so with *one* click on the numberOfCommentsLink24 , i get *two* calls to $('#listOfCommentsContainer25').slideToggle(450); which basically slides up, and immediately down. that is, slide toggle means it goes up (hides) if it was down (visible), it goes down (shows) if it was up (hidden). i want to avoid this behaviour by stopping the ajax response from spitting back the javascript code for a second time. perhaps do something inside the behaviour class? hope it clarifies! thanks, francisco On Thu, Nov 6, 2008 at 1:53 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Im not sure I understand then..? Could you explain another way? You would want to not output the list with wicket's ordinary ajax replace method? francisco treacy wrote: yes, i'm aware of those. but i'd
setResponsePage + anchor
Hi, I know you can set an anchor when you are coming from a Link component, but how can I set an anchor without the Link? From a Button's onSubmit, I am calling setResponsePage with a Page instance, and have a reference to a component on that page that I would like the browser to jump directly to. From my research so far, I don't believe this to be possible, but easily could have missed something! Is there a way to do this? Regards, Charlie.
Re: Looking for the previous thread about pagingnavigator with infinite pages
yes that was it, thanks very much.. Wayne Pope wrote: not sure if this is the one you mean - it was titled : Is there any other way? DataProviders must hit the Db twice On Wed, Dec 3, 2008 at 3:41 PM, Serkan Camurcuoglu [EMAIL PROTECTED] wrote: Hi all, Sorry for disturbing but I remember I've read a discussion about implementing a paging navigator for an unknown (possibly infinite) number of pages in the list recently, but I haven't been able to find it on Nabble. Can somebody send me the link of this thread if you can find or remember the original discussion? Best regards, SerkanC - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: avoid ajax response evaluate javascript
thanks for the hint, martin. ServletWebRequest request = (ServletWebRequest) RequestCycle.get().getRequest(); if (!request.isAjax()) { response.renderJavascriptReference(new JQueryEffectCoreResourceReference()); (...) } in renderHead() seems to do the trick. francisco On Thu, Dec 4, 2008 at 12:56 PM, Martin Makundi [EMAIL PROTECTED] wrote: There is ServletWebRequest.isAjax ** Martin 2008/12/4 francisco treacy [EMAIL PROTECTED]: i've been using the aforementioned toggle behavior almost always in ajaxy pages, and in that case they work fine. basically that means i add toggle behaviors to components in a page. when i call an ajax link, toggle works ok because the isTemporary() method of the behavior returns *true* (otherwise it would attach the toggle effect contribution to the header-contribution part of the response and it would blow things up - i.e. triggering more than once a certain toggle effect). however, i now started using that in pages that use normal links (not ajax). so when i get the (non ajax) response for the linked page, as the behavior is temporary, it won't contribute to the header anymore. thus breaking the effect. say page1 links to page1b [a new version of page1] when i diff page1 page1b i roughly get this: 24,28d23 script type=text/javascript src=resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js/script script type=text/javascript !--/*--![CDATA[/*!--*/ Wicket.Event.add(window, domready, function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;}); /*--]]*//script i.e. the toggle effect won't work in page1b because function() { $('#optionalInfoLink58').click(function() { $('#OptionalInfoArea59').slideToggle(450); }) ;} is not present in that page at all. note this doesn't pose a problem if i refresh certain components via ajax because the original page still contains this javascript listener in the header. my question: is there a way to tell inside isTemporary() whether the request was ajax or normal, to return true or false according to that? other suggestions? francisco On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy [EMAIL PROTECTED] wrote: It did.. You could try the isTemporary (return true) on the behavior, it thanks nino... that *is* the solution, works like a charm my mistake for not paying attention to the last bits of the javadoc ibehavior page :) boolean isTemporary() Specifies whether or not this behavior is temporary. Temporary behaviors are removed at the end of request. Such behaviors are useful for modifying component rendering only when it renders next. Usecases include javascript effects, initial clientside dom setup, etc. ... couldn't be more clear... cheers, francisco On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Hi Francisco It did.. You could try the isTemporary (return true) on the behavior, it could mean that it will only add the behavior for that request, but I am not sure.. Or you could try creating a new markupcontainer (listOfCommentsContainer), it'll give it a new id.. Or you could stuff in some logic as a ajaxcalldecorator on your link, that will clean it up in pure js... I had some difficulties with exactly this when I did the wicket reaction game. I hope this helpes.. francisco treacy wrote: want to not output the list with wicket's ordinary ajax replace method? hmmm... wicket's ordinary ajax replace method? the basic problem here is: -when the page is first rendered, the following is added to the dom (it's the behaviour responsible for this): $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) -when i click on the trigger link (numberOfCommentsLink24) i fire an ajax request, and add a webmarkupcontainer (listOfCommentsContainer25) i want to refresh: target.addComponent(listOfCommentsContainer); -the ajax response is: *not only* the updated listOfCommentsContainer25, but *also* an evaluate section in the ajax response, that includes: $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) (of course, because the behaviour has been added to the listOfCommentsContainer). -... that means, i now have loaded in the dom *twice* : $('#numberOfCommentsLink24').click(function() { $('#listOfCommentsContainer25').slideToggle(450); }) so with *one* click on the numberOfCommentsLink24 , i get *two* calls to $('#listOfCommentsContainer25').slideToggle(450); which basically slides up, and immediately down. that is, slide toggle means it goes up (hides) if it was down (visible), it goes down (shows) if it was up (hidden). i want to avoid this behaviour by stopping the ajax response from spitting back the javascript code for a second time. perhaps do
How to feed ListMultipleChoice with comma separated String via PropertyModel)
Hi everybody, I wonder if there is an elegant way to feed a ListMultipleChoice component with a comma separated string (using a PropertyModel) e.g. with the following property to be accessed by PropertyModel: public String getMySelectedOptions() { return optionA,optionC; } ...something like this: ListString allOptions = Arrays.asList(new String[]{optionA,optionB,optionC,optionD}); new CheckBoxMultipleChoice(genreChoice, new PropertyModel(getModel(), mySelectedOptions)), allOptions); Of course this does not work. But is there a elegant solution to make it work? I am thinking of something acting similar to a converter for text input fields, just the other way round :) Thanks for any inspiration -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20834160.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: updating a page when external event occurs
Here is how I solved the problem. I extended AjaxSelfUpdatingTimerBehavior and overrid onPostProcessTarget(). inside method I replace the table wicket ( because the DefaultDataTable does not seem able to dynamically add column); I created a borderwicket containing the table, added the timer to it and, by miracle, it Works!!! :jumping: Up to now the wicket library seems to me very good, but it's very hard for a beginner to figure out what the methods do. Marino marino wrote: Hello, I have a simple wicket application built around the DefaulDataTable example. In the same program I have an Event Listener class which is called outside the wicket application context. This class produces data that I would like to show in the current wicket page, but when I call any operation like add(), replaceWith() .. I always receive the message: WicketRuntimeException: There is no application attached to current thread ... What can I do? Thanks, Marino -- View this message in context: http://www.nabble.com/updating-a-page-when-external-event-occurs-tp20770960p20834366.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to feed ListMultipleChoice with comma separated String via PropertyModel)
I would just create a model that wraps the property model and does the conversion. On Thu, Dec 4, 2008 at 9:12 AM, pixologe [EMAIL PROTECTED] wrote: Hi everybody, I wonder if there is an elegant way to feed a ListMultipleChoice component with a comma separated string (using a PropertyModel) e.g. with the following property to be accessed by PropertyModel: public String getMySelectedOptions() { return optionA,optionC; } ...something like this: ListString allOptions = Arrays.asList(new String[]{optionA,optionB,optionC,optionD}); new CheckBoxMultipleChoice(genreChoice, new PropertyModel(getModel(), mySelectedOptions)), allOptions); Of course this does not work. But is there a elegant solution to make it work? I am thinking of something acting similar to a converter for text input fields, just the other way round :) Thanks for any inspiration -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20834160.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to feed ListMultipleChoice with comma separated String via PropertyModel)
Thanks for the reply... that's exactly what I just tried, until I realized that this will not work for writing the selected options back to the my domain object... at least I think so: I can teach the model to accept either String and List in setObject, however there's no way of letting it return different types in getObject, depending on the requestor... Or am I just completely on the wrong track and missing something quite obvious? Probably ;-) jwcarman wrote: I would just create a model that wraps the property model and does the conversion. On Thu, Dec 4, 2008 at 9:12 AM, pixologe [EMAIL PROTECTED] wrote: Hi everybody, I wonder if there is an elegant way to feed a ListMultipleChoice component with a comma separated string (using a PropertyModel) e.g. with the following property to be accessed by PropertyModel: public String getMySelectedOptions() { return optionA,optionC; } ...something like this: ListString allOptions = Arrays.asList(new String[]{optionA,optionB,optionC,optionD}); new CheckBoxMultipleChoice(genreChoice, new PropertyModel(getModel(), mySelectedOptions)), allOptions); Of course this does not work. But is there a elegant solution to make it work? I am thinking of something acting similar to a converter for text input fields, just the other way round :) Thanks for any inspiration -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20834160.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20835144.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to feed ListMultipleChoice with comma separated String via PropertyModel)
How about something like this: public class CommaSeparatedToStringListModel implements IModelListString { private final IModelString csvModel; public CommaSeparatedToStringListModel(final IModelString csvModel) { this.csvModel = csvModel; } public ListString getObject() { return new ArrayListString(Arrays.asList(csvModel.getObject().split(,))); } public void setObject(final ListString strings) { StringBuilder builder = new StringBuilder(); for (String string : strings) { if(builder.length() 0) { builder.append(,); } builder.append(string); } csvModel.setObject(builder.toString()); } public void detach() { csvModel.detach(); } } On Thu, Dec 4, 2008 at 10:00 AM, pixologe [EMAIL PROTECTED] wrote: Thanks for the reply... that's exactly what I just tried, until I realized that this will not work for writing the selected options back to the my domain object... at least I think so: I can teach the model to accept either String and List in setObject, however there's no way of letting it return different types in getObject, depending on the requestor... Or am I just completely on the wrong track and missing something quite obvious? Probably ;-) jwcarman wrote: I would just create a model that wraps the property model and does the conversion. On Thu, Dec 4, 2008 at 9:12 AM, pixologe [EMAIL PROTECTED] wrote: Hi everybody, I wonder if there is an elegant way to feed a ListMultipleChoice component with a comma separated string (using a PropertyModel) e.g. with the following property to be accessed by PropertyModel: public String getMySelectedOptions() { return optionA,optionC; } ...something like this: ListString allOptions = Arrays.asList(new String[]{optionA,optionB,optionC,optionD}); new CheckBoxMultipleChoice(genreChoice, new PropertyModel(getModel(), mySelectedOptions)), allOptions); Of course this does not work. But is there a elegant solution to make it work? I am thinking of something acting similar to a converter for text input fields, just the other way round :) Thanks for any inspiration -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20834160.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-feed-ListMultipleChoice-with-comma-separated-String-via-PropertyModel%29-tp20834160p20835144.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: IChainingModel
John, Well spotted. AbstractPropertyModel implements IChainingModel but breaks its contract : * Models that implement this interface will support chaining of IModels. getObject() of a * IChainingModel should do something like: * * pre * if ( object instanceof IModel) { return ((IModel)object).getObject()} * else return object; * /pre Its getObject() implementation does not abide by this. /** * @see org.apache.wicket.model.IModel#getObject() */ public Object getObject() { final String expression = propertyExpression(); if (Strings.isEmpty(expression)) { // Return a meaningful value for an empty property expression return getTarget(); } final Object target = getTarget(); if (target != null) { return PropertyResolver.getValue(expression, target); } return null; } Regards - Cemal http://www.jWeekend.co.uk http://jWeekend.co.uk John Patterson wrote: Hi, I'm messing about with nested models and see the IChainingModel interface which is implemented by the PropertyModels but its methods never actually seems to be used. So I'm just checking that I haven't missed anything... for nested models I don't actually need to implement this right? This is its def: public interface IChainingModelT extends IModelT { /** * Sets the model that is chained inside this model. * * @param model */ public void setChainedModel(IModel ? model); /** * Returns the chained model if there is a chained model. * * @return The chained model */ public IModel ? getChainedModel(); } Thanks, John -- View this message in context: http://www.nabble.com/IChainingModel-tp20835085p20835745.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clearing Cache after Logout
Thanks for the reply there Nino. I have set up a custom expired page and have set the following in Application class getApplicationSettings().setPageExpiredErrorPage(PageExpired.class); Now the page expired is set to this page. But still on hitting the back button I get back to the page. I tried using the SimplePageAuthorizationStrategy in my Application.init() method. The code that put in there looks something like this SimplePageAuthorizationStrategy authorizationStrategy = new SimplePageAuthorizationStrategy( LimitManagerPage.class, PageExpired.class) { protected boolean isAuthorized() { // Authorize access based on user authentication in the session if(((WebSession) Session.get()).isSessionInvalidated()){ return false; } else { return true; } } }; getSecuritySettings().setAuthorizationStrategy(authorizationStrategy); But this doesn't provide the desired result as well. This doesn't even show my custom PageExpired web page. Any ideas about why this is not working or something else that I can do to get this to work. Thanks in advance, vishy -- View this message in context: http://www.nabble.com/Clearing-Cache-after-Logout-tp20823965p20837005.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clearing Cache after Logout
you can set your application's home page as your expired page or throw a restartresponseexception (to home page) from the constructor of your page expired page.. at least I do it that way.. vishy_sb wrote: Thanks for the reply there Nino. I have set up a custom expired page and have set the following in Application class getApplicationSettings().setPageExpiredErrorPage(PageExpired.class); Now the page expired is set to this page. But still on hitting the back button I get back to the page. I tried using the SimplePageAuthorizationStrategy in my Application.init() method. The code that put in there looks something like this SimplePageAuthorizationStrategy authorizationStrategy = new SimplePageAuthorizationStrategy( LimitManagerPage.class, PageExpired.class) { protected boolean isAuthorized() { // Authorize access based on user authentication in the session if(((WebSession) Session.get()).isSessionInvalidated()){ return false; } else { return true; } } }; getSecuritySettings().setAuthorizationStrategy(authorizationStrategy); But this doesn't provide the desired result as well. This doesn't even show my custom PageExpired web page. Any ideas about why this is not working or something else that I can do to get this to work. Thanks in advance, vishy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Wicket integration with good charts api
Really interested by a Wiki page too. -- View this message in context: http://www.nabble.com/Wicket-integration-with-good-charts-api-tp20322515p20837861.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clearing Cache after Logout
That you get back to your last page when hitting the back button has nothing to do with Wicket. It's just what browsers do when you hit the back button. I guess you are using firefox (3), and firefox 3 will show a page from its in-memory cache, even if the page headers tell it the page is expired long ago, must be reloaded, and must be revalidated (which is what wicket tells it by default). Google on firefox cache reload or something for how firefox caches pages and for suggestions on how to force a page reload. On Thu, 04 Dec 2008 18:35:09 +0200, Serkan Camurcuoglu [EMAIL PROTECTED] said: you can set your application's home page as your expired page or throw a restartresponseexception (to home page) from the constructor of your page expired page.. at least I do it that way.. vishy_sb wrote: Thanks for the reply there Nino. I have set up a custom expired page and have set the following in Application class getApplicationSettings().setPageExpiredErrorPage(PageExpired.class); Now the page expired is set to this page. But still on hitting the back button I get back to the page. I tried using the SimplePageAuthorizationStrategy in my Application.init() method. The code that put in there looks something like this SimplePageAuthorizationStrategy authorizationStrategy = new SimplePageAuthorizationStrategy( LimitManagerPage.class, PageExpired.class) { protected boolean isAuthorized() { // Authorize access based on user authentication in the session if(((WebSession) Session.get()).isSessionInvalidated()){ return false; } else { return true; } } }; getSecuritySettings().setAuthorizationStrategy(authorizationStrategy); But this doesn't provide the desired result as well. This doesn't even show my custom PageExpired web page. Any ideas about why this is not working or something else that I can do to get this to work. Thanks in advance, vishy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: setResponsePage + anchor
I'm doing it like this from my Page: @Override public void renderHead(IHeaderResponse response) { if (anchor != null) { response.renderOnLoadJavascript(location.href='# + anchor + ';); anchor = null; } } Just have a setter for the anchor property on the Page instance you pass to setResponsePage(). janos On Thu, Dec 4, 2008 at 1:53 PM, Charlie Dobbie [EMAIL PROTECTED] wrote: Hi, I know you can set an anchor when you are coming from a Link component, but how can I set an anchor without the Link? From a Button's onSubmit, I am calling setResponsePage with a Page instance, and have a reference to a component on that page that I would like the browser to jump directly to. From my research so far, I don't believe this to be possible, but easily could have missed something! Is there a way to do this? Regards, Charlie. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
login using AuthenticatedWebApplication
I am using AuthenticatedWebApplication , the example documents how to control access to pages with roles using annotations ,but In my case i have some users without any role , can I prevent access to my aplication for these users ? -- View this message in context: http://www.nabble.com/login--using-AuthenticatedWebApplication-tp20840439p20840439.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Openid integration?
Hi Nino, It is possibile to integrate spring security with the wicket swarm/ wasp software. This gives you freedom to attach any kind of authentication mechanism, including openid. We use the integration for a LDAP based integration. If you like, I have a sample on how to deal with this somewhere. Kind Regards, Olger On 3 dec 2008, at 07:31, Nino Saturnino Martinez Vazquez Wael wrote: Hmm, i'll dig into it.. Thanks.. Jan Kriesten wrote: Hi Nino, I have something working only partially though, cant get email and name attribute back from the openid provider properly.. Seems to work with openid.org, but not claimid.com or myopenid.com why not using spring-security and don't have any more hassle at all? Best regards, --- Jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using annotation @AuthorizeInstantiation
I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . -- View this message in context: http://www.nabble.com/using--annotation-%40AuthorizeInstantiation-tp20841729p20841729.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AjaxSelfUpdatingBehavior problem with HttpSessionStore
Hi everybody, Recently we discovered that SecondLevelCacheSessionStore was giving us a huge performance hit in some of our applications, so we decided to the old HttpSessionStore. Performance increase was significant and the impact on memory usage was relatively small, so we decided to stick with it. But we also discovered a problem when using AjaxSelfUpdatingbehavior combined with ajax buttons (when ajax button forwards to another page (let's call is PageB) by setResponsePage method). When a user hits a button and immediately after that an ajax request is fired by the AjaxSelfUpdatingbehavior, AccessStackPageMap thinks that user has pressed back button. This is what happens when this behavior occurs: 1) User pressed an ajax button 2) AjaxSelUpdatingBehavior fires another ajax request right after user pressed button 3) User ends up on PageB 4) now pressing ajax buttons on a new page has no effect WebRequestCycleProcessor's resolve method goes now to line 114: if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } Wicket Ajax Debug prints something like this: INFO: Initiating Ajax POST request on ? wicket:interface=:1:inputForm:back::IActivePageBehaviorListener:0:wicket:ignoreIfNotActive=truerandom=0.6741350924814413 INFO: Invoking pre-call handler(s)... INFO: Received ajax response (31 characters) INFO: ajax-response/ajax-response ERROR: Error while parsing response: Could not find root ajax-response element INFO: Invoking post-call handler(s)... We debugged around a bit and discovered that when this behavior happens, AccessStackPageMap's accept method is called with instance of PageB as entry parameter. But instantly after that a request that came from AjaxSelfUpdatingBehavior calls also AccessStackPageMap's accept method (entry is now the page where AjaxSelfUpdatingBehavior was added). Now reference of PageB is removed from stack and AccessStackPagemap thinks that user is on previous page while user is really on PageB. I made simplest possible quickstart application that behaves like this. I put an AjaxSelfUpdatingBehavior to update a component on a page at 2 second intervals. Then I added an Ajax link and in its onSubmit method I put thread to sleep for 3 seconds before setResponsePage is called. That way this behavior can be repeated always when pressing the button. If the sleep is removed then of course this happens rarely, but in our real life application it shows up very frequently. Should I open a JIRA issue on this and attatch my quickstart application to it? Regards, Mikko
RE: AjaxSelfUpdatingBehavior problem with HttpSessionStore
Hi, Sorry, I forgot to mention that the wicket version we are using, is 1.3.5 - Mikko Lähettäjä: Mikko Pukki [EMAIL PROTECTED] Lähetetty: 4. joulukuuta 2008 22:29 Vastaanottaja: users@wicket.apache.org Aihe: AjaxSelfUpdatingBehavior problem with HttpSessionStore Hi everybody, Recently we discovered that SecondLevelCacheSessionStore was giving us a huge performance hit in some of our applications, so we decided to the old HttpSessionStore. Performance increase was significant and the impact on memory usage was relatively small, so we decided to stick with it. But we also discovered a problem when using AjaxSelfUpdatingbehavior combined with ajax buttons (when ajax button forwards to another page (let's call is PageB) by setResponsePage method). When a user hits a button and immediately after that an ajax request is fired by the AjaxSelfUpdatingbehavior, AccessStackPageMap thinks that user has pressed back button. This is what happens when this behavior occurs: 1) User pressed an ajax button 2) AjaxSelUpdatingBehavior fires another ajax request right after user pressed button 3) User ends up on PageB 4) now pressing ajax buttons on a new page has no effect WebRequestCycleProcessor's resolve method goes now to line 114: if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } Wicket Ajax Debug prints something like this: INFO: Initiating Ajax POST request on ? wicket:interface=:1:inputForm:back::IActivePageBehaviorListener:0:wicket:ignoreIfNotActive=truerandom=0.6741350924814413 INFO: Invoking pre-call handler(s)... INFO: Received ajax response (31 characters) INFO: ajax-response/ajax-response ERROR: Error while parsing response: Could not find root ajax-response element INFO: Invoking post-call handler(s)... We debugged around a bit and discovered that when this behavior happens, AccessStackPageMap's accept method is called with instance of PageB as entry parameter. But instantly after that a request that came from AjaxSelfUpdatingBehavior calls also AccessStackPageMap's accept method (entry is now the page where AjaxSelfUpdatingBehavior was added). Now reference of PageB is removed from stack and AccessStackPagemap thinks that user is on previous page while user is really on PageB. I made simplest possible quickstart application that behaves like this. I put an AjaxSelfUpdatingBehavior to update a component on a page at 2 second intervals. Then I added an Ajax link and in its onSubmit method I put thread to sleep for 3 seconds before setResponsePage is called. That way this behavior can be repeated always when pressing the button. If the sleep is removed then of course this happens rarely, but in our real life application it shows up very frequently. Should I open a JIRA issue on this and attatch my quickstart application to it? Regards, Mikko - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Another Ajax back button question
I'm sure this has been asked and answered but after searching the list, I'm still not sure if there is something I can do to fix my situation. The general gist is this: 1) I make some changes to a page with ajax calls (i.e. replace panel contents) 2) Click a link to take me away from that page 3) Use browser back button to return to previous page 4) Original page is in the state that it was BEFORE the changes made with the ajax calls. Maybe this is a, Well, duh.. of course it is. That's just the way it works moment, but I could have sworn I've seen this work differently in other wicket examples and apps I've worked on. Any tips? -Matt -- View this message in context: http://www.nabble.com/Another-Ajax-back-button-question-tp20843893p20843893.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Ajax back button question
If the ajax changes are reflected in the relevant model(s) then you will see them when you go back to the page. Scott On Thu, Dec 4, 2008 at 2:29 PM, Matt Welch [EMAIL PROTECTED] wrote: I'm sure this has been asked and answered but after searching the list, I'm still not sure if there is something I can do to fix my situation. The general gist is this: 1) I make some changes to a page with ajax calls (i.e. replace panel contents) 2) Click a link to take me away from that page 3) Use browser back button to return to previous page 4) Original page is in the state that it was BEFORE the changes made with the ajax calls. Maybe this is a, Well, duh.. of course it is. That's just the way it works moment, but I could have sworn I've seen this work differently in other wicket examples and apps I've worked on. Any tips? -Matt -- View this message in context: http://www.nabble.com/Another-Ajax-back-button-question-tp20843893p20843893.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Ajax back button question
If you want to manage all the back button events, i suggest you to use a simple bookmarking library.likeRSH We use the ajax calls to insert some tag that went added to the address after #. (target.prependjavcascript). After that, when going back to another tag, there was a script defined on the body onload method with RSH libraries. There, if the tag was one of the tags that should activate back button support, we simulated the click of an ajaxbutton to replace the current state of the page with the previous state.This was done with javascript and java code in wicket. In our project, we used RSH(http://code.google.com/p/reallysimplehistory/). 2008/12/4 Scott Swank [EMAIL PROTECTED] If the ajax changes are reflected in the relevant model(s) then you will see them when you go back to the page. Scott On Thu, Dec 4, 2008 at 2:29 PM, Matt Welch [EMAIL PROTECTED] wrote: I'm sure this has been asked and answered but after searching the list, I'm still not sure if there is something I can do to fix my situation. The general gist is this: 1) I make some changes to a page with ajax calls (i.e. replace panel contents) 2) Click a link to take me away from that page 3) Use browser back button to return to previous page 4) Original page is in the state that it was BEFORE the changes made with the ajax calls. Maybe this is a, Well, duh.. of course it is. That's just the way it works moment, but I could have sworn I've seen this work differently in other wicket examples and apps I've worked on. Any tips? -Matt -- View this message in context: http://www.nabble.com/Another-Ajax-back-button-question-tp20843893p20843893.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Where can I download wicket extensions?
The most logical place would be at http://www.wicketframework.org/wicket-extensions/. However the link to the sourceforge site from there gives me old code(1.2.7). I have a jar right now that is 1.3.2 and I'm not sure where it came from. I need the source code so I can customize the wizard component. Please help. Thanks, Josh -- View this message in context: http://www.nabble.com/Where-can-I-download-wicket-extensions--tp20844206p20844206.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Another Ajax back button question
Scott Swank wrote: If the ajax changes are reflected in the relevant model(s) then you will see them when you go back to the page. Hmmm... perhaps I shouldn't have abstracted my issue and instead discussed exactly what is happening. Let me change some steps. 1) On a page with a form I enter information and submit the form 2) The page refreshes (normal submit; not ajax) and a panel that was previously invisible is displayed as the form submission is processed in the background. This processing is background task because it can take a very long time (anywhere between 5 seconds to half an hour). There is an AjaxSelfUpdatingTimerBehavior with a 5 seconds time attached to the now visible panel. 3) The AjaxSelfUpdatingTimerBehavior checks the background process in it's onPostProcessTarget() method and when the background processing is done, the panel is made invisible again and new panel is made visible with a link to report on the processing that just took place. 4) Clicking that link takes one to the report and then clicking that browser back button brings one back to the form page, however, it apparently brings one back to the form page in the state it was just after the original submit was clicked. The actual background processing doesn't get kicked off again, but the in progress panel is visible and remains visible until one cycle of the AjaxSelfUpdatingTimerBehavior goes by and then the page returns to the expected state. I'd like to figure out a way keep that in progress panel from showing up when the back button is pressed. -Matt -- View this message in context: http://www.nabble.com/Another-Ajax-back-button-question-tp20843893p20844322.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Non-Modal-Popop with DOJO-CONTEXT-Menu
Hi, i want to create a new browser-window from a wicket-dojo popup menu (non modal!). the popup is a pure javascript solution. in wicket there is a possibility using popupsettings within a link. a) is it possible to switch the request to a new browser-window? (RequestCycle.get()) b) exist any non-modal window, creating from java-sourcecode, so i can start the window in onClick method? c) is it possible to add a link to the dojo-popup thanks a lot... regards Alexander Elsholz -- View this message in context: http://www.nabble.com/Non-Modal-Popop-with-DOJO-CONTEXT-Menu-tp20844570p20844570.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where can I download wicket extensions?
Maven makes this really easy, but if you are managing your jars yourself, you can still use the Maven repo as a source: http://repo1.maven.org/maven2/org/apache/wicket/ http://repo1.maven.org/maven2/org/apache/wicket/wicket-extensions/1.3.2/ Or you can go to the main wicket homepage (wicket.apache.org) and click on the donwload link for 1.3 - where you can download a zip that has all of the source and built jars for Wicket. This is for the latest 1.3 - 1.3.5, but you should upgrade anyway if at all possible. -- Jeremy Thomerson http://www.wickettraining.com On Thu, Dec 4, 2008 at 4:45 PM, jchappelle [EMAIL PROTECTED] wrote: The most logical place would be at http://www.wicketframework.org/wicket-extensions/. However the link to the sourceforge site from there gives me old code(1.2.7). I have a jar right now that is 1.3.2 and I'm not sure where it came from. I need the source code so I can customize the wizard component. Please help. Thanks, Josh -- View this message in context: http://www.nabble.com/Where-can-I-download-wicket-extensions--tp20844206p20844206.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
@SpringBean with page creation patterns
Hi Everyone, I'm just getting started with wicket and am learning by playing around with building an ecommerce application on top of wicket, spring and hibernate. I've been (Ha!) using @SpringBean to inject my spring dependencies and am very impressed with it. One thing I'm wondering about is how to use @SpringBean with a pattern in the 'wicket in action' book. Specifically, when creating a bookmarkablePageLink with pageparameters this pattern is used: public class CheeseDetailsPage extends WebPage { // bookmarkable constructor public CheeseDetailsPage(PageParameters parameters) { #1 this(getCheese(parameters)); } // non-bookmarkable constructor public CheeseDetailsPage(Cheese cheese) { #2 // do cheesy stuff with the cheese } /** Retrieves a cheese object based on the ‘name’ parameter. */ public static Cheese getCheese(PageParameters parameters) { #3 String name = parameters.getString(name, ); if(.equals(name)) return null; CheeseDao dao = ...; return dao.getCheeseByName(name); } } I like this pattern but i'm having a problem with injecting my dependencies. The getCheese() method is static, which means that the CheeseDao would have to be static. I haven't delved into the code of the @SpringBean proxy or the wicket serialization code (I have read the wiki on @SpringBean) and I don't have an amazing understanding of proxies so maybe i'm just being obtuse but heres my question. Is there any reason not to make the DAO static? Cheers in advance -- View this message in context: http://www.nabble.com/%40SpringBean-with-page-creation-patterns-tp20845794p20845794.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to print only one validation message from a listview of radiobuttons
Hi, I have a ListView containing several RadioButtons.setRequired(true) (a Q A list) that are all required to be answered. However, if someone doesn't click on all of the radio buttons, I see three Please answer the question messages on the feedback panel. How can I just consolidate it so only one message appears if any of the questions i.e. radiobuttons is not selected? Thanks, Jason -- View this message in context: http://www.nabble.com/how-to-print-only-one-validation-message-from-a-listview-of-radiobuttons-tp20846684p20846684.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED]wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
Well... You don't have to create one java file for each class. You can put all of them on the same file, like: public final class MyAppRoles { private MyAppRoles() {} public static final class Admin extends Role { private Admin() {} } public static final class User extends Role { private User() {} } } Note that this is really type-safe, and these classes will never be instantiated. But, I'm not defending that we should change that. I'm just showing a possibility. :-) I really did't understand why Sun decided to reject Enums as Objects in this context of annotations. cheers, Bruno James Carman wrote: I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED]wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
What do you mean by Enums as Objects? On Thu, Dec 4, 2008 at 11:11 PM, Bruno Borges [EMAIL PROTECTED]wrote: Well... You don't have to create one java file for each class. You can put all of them on the same file, like: public final class MyAppRoles { private MyAppRoles() {} public static final class Admin extends Role { private Admin() {} } public static final class User extends Role { private User() {} } } Note that this is really type-safe, and these classes will never be instantiated. But, I'm not defending that we should change that. I'm just showing a possibility. :-) I really did't understand why Sun decided to reject Enums as Objects in this context of annotations. cheers, Bruno James Carman wrote: I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED] wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
Well... you can't do this: @Foo(values={MyEnum.FOO, MyEnum.BAR}); @interface Foo { Object[] values() default {}; } James Carman wrote: What do you mean by Enums as Objects? On Thu, Dec 4, 2008 at 11:11 PM, Bruno Borges [EMAIL PROTECTED]wrote: Well... You don't have to create one java file for each class. You can put all of them on the same file, like: public final class MyAppRoles { private MyAppRoles() {} public static final class Admin extends Role { private Admin() {} } public static final class User extends Role { private User() {} } } Note that this is really type-safe, and these classes will never be instantiated. But, I'm not defending that we should change that. I'm just showing a possibility. :-) I really did't understand why Sun decided to reject Enums as Objects in this context of annotations. cheers, Bruno James Carman wrote: I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED] wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
But, you can declare the values property to be of type MyEnum[]. Is what we're really looking for here the ability to extend an enum (if that even makes sense)? I've often thought it would be nice if I could add stuff to an enum from the outside. But, that kind of goes against the idea of an enum, doesn't it? On Thu, Dec 4, 2008 at 11:51 PM, Bruno Borges [EMAIL PROTECTED]wrote: Well... you can't do this: @Foo(values={MyEnum.FOO, MyEnum.BAR}); @interface Foo { Object[] values() default {}; } James Carman wrote: What do you mean by Enums as Objects? On Thu, Dec 4, 2008 at 11:11 PM, Bruno Borges [EMAIL PROTECTED] wrote: Well... You don't have to create one java file for each class. You can put all of them on the same file, like: public final class MyAppRoles { private MyAppRoles() {} public static final class Admin extends Role { private Admin() {} } public static final class User extends Role { private User() {} } } Note that this is really type-safe, and these classes will never be instantiated. But, I'm not defending that we should change that. I'm just showing a possibility. :-) I really did't understand why Sun decided to reject Enums as Objects in this context of annotations. cheers, Bruno James Carman wrote: I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED] wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to print only one validation message from a listview of radiobuttons
Should you be using a RadioChoice instead? novotny wrote: Hi, I have a ListView containing several RadioButtons.setRequired(true) (a Q A list) that are all required to be answered. However, if someone doesn't click on all of the radio buttons, I see three Please answer the question messages on the feedback panel. How can I just consolidate it so only one message appears if any of the questions i.e. radiobuttons is not selected? Thanks, Jason -- View this message in context: http://www.nabble.com/how-to-print-only-one-validation-message-from-a-listview-of-radiobuttons-tp20846684p20847927.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
It is not possible to extend enums nor annotations. And as the question here is about the use of @AuthorizeInstantiation, there's no way to declare MyEnum[], of course :-) So, the only way, for now, to have type-safety is using that Class-thing. I don't vote for this though. A simple class with String constants does de job quite well. :-D James Carman wrote: But, you can declare the values property to be of type MyEnum[]. Is what we're really looking for here the ability to extend an enum (if that even makes sense)? I've often thought it would be nice if I could add stuff to an enum from the outside. But, that kind of goes against the idea of an enum, doesn't it? On Thu, Dec 4, 2008 at 11:51 PM, Bruno Borges [EMAIL PROTECTED]wrote: Well... you can't do this: @Foo(values={MyEnum.FOO, MyEnum.BAR}); @interface Foo { Object[] values() default {}; } James Carman wrote: What do you mean by Enums as Objects? On Thu, Dec 4, 2008 at 11:11 PM, Bruno Borges [EMAIL PROTECTED] wrote: Well... You don't have to create one java file for each class. You can put all of them on the same file, like: public final class MyAppRoles { private MyAppRoles() {} public static final class Admin extends Role { private Admin() {} } public static final class User extends Role { private User() {} } } Note that this is really type-safe, and these classes will never be instantiated. But, I'm not defending that we should change that. I'm just showing a possibility. :-) I really did't understand why Sun decided to reject Enums as Objects in this context of annotations. cheers, Bruno James Carman wrote: I don't know about this. It would work (and break existing code, unless you use something other than value for the annotation). I don't know if I would want to have to create a new class for each role in my project. Yes, it would be a small price to pay, but it just feels wrong. On Thu, Dec 4, 2008 at 10:33 PM, Bruno Borges [EMAIL PROTECTED] wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ http://www.iam.unibe.ch/%7Eakuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.name()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,
Re: how to print only one validation message from a listview of radiobuttons
You can write a custom validator that checks all three and gives one message if any are not completed. Done correctly, it could be very reusable - give it an array of components that it checks and a resource key to get the message. On Thu, Dec 4, 2008 at 8:22 PM, novotny [EMAIL PROTECTED] wrote: Hi, I have a ListView containing several RadioButtons.setRequired(true) (a Q A list) that are all required to be answered. However, if someone doesn't click on all of the radio buttons, I see three Please answer the question messages on the feedback panel. How can I just consolidate it so only one message appears if any of the questions i.e. radiobuttons is not selected? Thanks, Jason -- View this message in context: http://www.nabble.com/how-to-print-only-one-validation-message-from-a-listview-of-radiobuttons-tp20846684p20846684.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jeremy Thomerson http://www.wickettraining.com
Re: IChainingModel
when you give propertymodel anoter imodel do you have to begin the expression with object to get the value out? -igor On Thu, Dec 4, 2008 at 7:31 AM, jWeekend [EMAIL PROTECTED] wrote: John, Well spotted. AbstractPropertyModel implements IChainingModel but breaks its contract : * Models that implement this interface will support chaining of IModels. getObject() of a * IChainingModel should do something like: * * pre * if ( object instanceof IModel) { return ((IModel)object).getObject()} * else return object; * /pre Its getObject() implementation does not abide by this. /** * @see org.apache.wicket.model.IModel#getObject() */ public Object getObject() { final String expression = propertyExpression(); if (Strings.isEmpty(expression)) { // Return a meaningful value for an empty property expression return getTarget(); } final Object target = getTarget(); if (target != null) { return PropertyResolver.getValue(expression, target); } return null; } Regards - Cemal http://www.jWeekend.co.uk http://jWeekend.co.uk John Patterson wrote: Hi, I'm messing about with nested models and see the IChainingModel interface which is implemented by the PropertyModels but its methods never actually seems to be used. So I'm just checking that I haven't missed anything... for nested models I don't actually need to implement this right? This is its def: public interface IChainingModelT extends IModelT { /** * Sets the model that is chained inside this model. * * @param model */ public void setChainedModel(IModel ? model); /** * Returns the chained model if there is a chained model. * * @return The chained model */ public IModel ? getChainedModel(); } Thanks, John -- View this message in context: http://www.nabble.com/IChainingModel-tp20835085p20835745.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using annotation @AuthorizeInstantiation
If you were going to do this, it would be much better (IMHO) to use interfaces... This gives you interesting possibilities: (Disclaimer - the following is not an original thought - Igor mentioned this last week - give credit where it's due) interface User interface Admin extends User interface ProjectManager extends Admin interface SalesManager extends Admin HERE'S THE KICKER: interface TheBigBoss extends ProjectManager, SalesManager Since those are just marker interfaces, I guess each of those would need something like a single public static final implementation like: public static final TheBigBoss INSTANCE = new TheBigBoss() {}; Something like that - anyway, MULTIPLE INHERITANCE FOR ROLES RULES! -- Jeremy Thomerson http://www.wickettraining.com On Thu, Dec 4, 2008 at 9:33 PM, Bruno Borges [EMAIL PROTECTED] wrote: I've found a way to implement a type-safe check for this. Here it goes: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @AuthorizeInstantiation(value = { User.class, Admin.class }) public class EnumAnnotation { } @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited @interface AuthorizeInstantiation { Class? extends Role[] value() default {}; } class Role { } class User extends Role { } class Admin extends Role { } So, the only thing that must change is the annotation @AuthorizeInstantiation, to accept classes that extends roles. Thoughts anyone? cheers, Bruno Bruno Borges wrote: You simply can't do that because the nature of Annotations. Even if AuthorizeInstantiation's values were of type Object[] you wouldn't be able to do that with Enums. You will have to use Strings. Although there's some hack you can make using Java 6 to accomplish what you want. If you are interested, take a look at this link: http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/ Good luck!! Cheers, Bruno miro wrote: I am using this @AuthorizeInstantiation (wicket authetication annotation) in my pages , the code for this annotation @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.PACKAGE, ElementType.TYPE }) @Documented @Inherited public @interface AuthorizeInstantiation { /** * Gets the roles that are allowed to take the action. * * @return the roles that are allowed. Returns a zero length array by default */ String[] value() default {}; } I created my enum with representing authorities public enum Authorities { LIASION_OFFICER, GRANTS_OFFICER, PROGRAM_ANALYST, ADMIN; } I am trying to use AuthorizeInstantiation in my page here an example @AuthorizeInstantiation(value={Authorities.LIASION_OFFICER.namehttp://authorities.liasion_officer.name/ ()}) public class HomePage extends BasePage { this line does not compile, I get the error The value of annotation attribute AuthorizeInstantiation .value must be a constant expression .please help me resolve this . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: IChainingModel
John, Cemal - that method in AbstractPropertyModel absolutely does abide by the contract - look at what it calls (getTarget()): public final Object getTarget() { Object object = target; while (object instanceof IModel) { Object tmp = ((IModel?)object).getObject(); if (tmp == object) break; object = tmp; } return object; } John - I think you're right - it is unnecessary to implement IChainingModel since there is no code in the wicket core codebase that calls it's methods. Just make sure that if you nest models inside of other custom models, you do call detach properly or you can end up with a memory leak. You can see this blog post as a simple example: http://www.jeremythomerson.com/blog/2008/11/06/wicket-the-power-of-nested-models/ Hope this helps. -- Jeremy Thomerson http://www.wickettraining.com On Thu, Dec 4, 2008 at 9:31 AM, jWeekend [EMAIL PROTECTED]wrote: John, Well spotted. AbstractPropertyModel implements IChainingModel but breaks its contract : * Models that implement this interface will support chaining of IModels. getObject() of a * IChainingModel should do something like: * * pre * if ( object instanceof IModel) { return ((IModel)object).getObject()} * else return object; * /pre Its getObject() implementation does not abide by this. /** * @see org.apache.wicket.model.IModel#getObject() */ public Object getObject() { final String expression = propertyExpression(); if (Strings.isEmpty(expression)) { // Return a meaningful value for an empty property expression return getTarget(); } final Object target = getTarget(); if (target != null) { return PropertyResolver.getValue(expression, target); } return null; } Regards - Cemal http://www.jWeekend.co.uk http://www.jweekend.co.uk/ http://jWeekend.co.uk http://jweekend.co.uk/ John Patterson wrote: Hi, I'm messing about with nested models and see the IChainingModel interface which is implemented by the PropertyModels but its methods never actually seems to be used. So I'm just checking that I haven't missed anything... for nested models I don't actually need to implement this right? This is its def: public interface IChainingModelT extends IModelT { /** * Sets the model that is chained inside this model. * * @param model */ public void setChainedModel(IModel ? model); /** * Returns the chained model if there is a chained model. * * @return The chained model */ public IModel ? getChainedModel(); } Thanks, John -- View this message in context: http://www.nabble.com/IChainingModel-tp20835085p20835745.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: @SpringBean with page creation patterns
I would recommend using a custom model for this. The advantage is that it can be used anywhere. Something like: // bookmarkable constructor public CheeseDetailsPage(PageParameters parameters) { #1 this(new CheeseByIDModel(getIDFromParams(parameters))); } // non-bookmarkable constructor public CheeseDetailsPage(IModelCheese cheese) { #2 // do cheesy stuff with the cheese } private statuc int getIDFromParams(PageParameters params) { return params.getInteger(foo); } Even better would be to do something very reusable like: new DomainEntityModelCheese(Cheese.class, getIDFromParameters(parameters)) See http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ for some ideas about this. On Thu, Dec 4, 2008 at 6:50 PM, quizzical [EMAIL PROTECTED] wrote: Hi Everyone, I'm just getting started with wicket and am learning by playing around with building an ecommerce application on top of wicket, spring and hibernate. I've been (Ha!) using @SpringBean to inject my spring dependencies and am very impressed with it. One thing I'm wondering about is how to use @SpringBean with a pattern in the 'wicket in action' book. Specifically, when creating a bookmarkablePageLink with pageparameters this pattern is used: public class CheeseDetailsPage extends WebPage { // bookmarkable constructor public CheeseDetailsPage(PageParameters parameters) { #1 this(getCheese(parameters)); } // non-bookmarkable constructor public CheeseDetailsPage(Cheese cheese) { #2 // do cheesy stuff with the cheese } /** Retrieves a cheese object based on the 'name' parameter. */ public static Cheese getCheese(PageParameters parameters) { #3 String name = parameters.getString(name, ); if(.equals(name)) return null; CheeseDao dao = ...; return dao.getCheeseByName(name); } } I like this pattern but i'm having a problem with injecting my dependencies. The getCheese() method is static, which means that the CheeseDao would have to be static. I haven't delved into the code of the @SpringBean proxy or the wicket serialization code (I have read the wiki on @SpringBean) and I don't have an amazing understanding of proxies so maybe i'm just being obtuse but heres my question. Is there any reason not to make the DAO static? Cheers in advance -- View this message in context: http://www.nabble.com/%40SpringBean-with-page-creation-patterns-tp20845794p20845794.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jeremy Thomerson http://www.wickettraining.com