Portlet Support
Has support for portlets been completely dropped from wicket? I was interested to see if I could get a simple portlet running in Liferay - Thanks -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Portlet-Support-tp4610364.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: BookmarkableLinks and masked urls
I think I've done it. I created a MaskedUrlCodingStrategyDecorator that extends from BookmarkablePageRequestTargetUrlCodingStrategy, placed it in the same package, and overrode CharSequence encode(IRequestTarget requestTarget), and used a regular BookmarkablePageLink -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/BookmarkableLinks-and-masked-urls-tp4610114p4610256.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
BookmarkableLinks and masked urls
The problem is that we have a brand new Wicket app, but we have a bunch of legacy urls that point to different sub domains that the business wants to preserve. So when the web server sees one of those urls there is a redirection to the app and that url is preserved, but in the app we have our own mounts. Some of those urls could look like: http://www.sub1.abc.net/param1/param2 http://www.sub2.abc.net/something/param1 Basically my links should point to the legacy urls and I can keep the way the page parameters are added. For the mean time I have created a factory that can return external and bookmarkable links depending on the class name, but I cannot take advantage of the url coding strategies already available for a specific page. I would like to go something like: BookmarkableMaskedPageLink link = new BookmarkableMaskedPageLink("link", MyPage.class, params); and I guess the url coding strategy could look like: MaskedUrlDecoratorStrategy mamboJamboCS = new MaskedUrlDecoratorStrategy( "http://www.sub2.abc.net/something"; MixedParamUrlCodingStrategy( "mambojambo", MyPage.class, new String[]{"param1", "param2"})); -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/BookmarkableLinks-and-masked-urls-tp4610114.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Store models short-term
Hi, Jason. Welcome to Wicket! If you want to tie an entity to a page, best save the entity within the page itself. You can do this by using a simple o.a.w.model.Model. If you don't want to detach between requests, then LDM is not a good fit. There are use cases where serializing entities at the app level (instead of the database) makes sense, such as wizards where saving prematurely results in an invalid data model. However, if your motivation is simply performance then I suggest you verify your assumptions. Retrieving entities by primary key is generally very fast, and if it's not fast then it's because it's really large and you probably don't want that serialized in the session anyway. The "optimization" is especially moot in clusters where the undetached entities are replicated across the network as part of the HTTP session. And there are other disadvantages such as having to deal with detached entities, with potentially stale state. I'll mention one hack for which another Wicket user should rightly reprimand me. As I mentioned recently, Wicket keeps the most recently accessed page is a deserialized state to optimize serving the next request. All components are still detached, but if you override IModel#detach() in your LDM and suppress super.detach() then your entity will hang around. This has the behavior you describe, since (1) the entity does not need to be reloaded on subsequent requests, and since it's object reference is transient (2) it goes away as soon as another page is accessed, and (3) it does not get replicated among the cluster. Best of luck, Dan On Fri, May 4, 2012 at 2:40 PM, JASON HOLT wrote: > > I'm new to Java and Wicket. My only previous experince with web > applications has been with Asp.net forms (not MVC). Please be patient; > coming from the postback event paradigm, I'm struggling to grasp the > concepts in Wicket. In my simple scenario, assume there is no AJAX. I need > to build the model from a database. If I use an LDM, on a postback Wicket > calls to the database to rebuild the model before updating it with the new > values. But if I don't use an LDM, Wicket will serialize the model in the > PageMap. I would like to keep the model 'in memory' long enough to process > the postback to avoid unecessary calls to the database, but release it when > I have moved on to a different page. I thought of something like this... In > the LDM @Override > public Object load() > { > ...somehow get the session. > if (session.getAttribute("PageAModel")!=null) > { >return (PageAModel)session.getAttribute("PageAModel"); > } > else > { >PageAModel pageAModel = ...build from database. >session.setAttribute("PageAModel", PageAModel); >return pageAModel; > } > } Then in the Page... @Override > public void onSubmit() > { > PageAModel pageAModel=(PageAModel)session.getAttribute("PageAModel"); > ...update the database with PageAModel pageAModel = > (PageAModel)ldm.getObject(); > ... //removes the model from session? > session.setAttribute("PageAModel")=null; > this.setResponsePage(...); > } I suspect there is a better way to handle this. Can I avoid using an > LDM, but somehow remove the model from the PageMap after leaving the page? >
Store models short-term
I'm new to Java and Wicket. My only previous experince with web applications has been with Asp.net forms (not MVC). Please be patient; coming from the postback event paradigm, I'm struggling to grasp the concepts in Wicket. In my simple scenario, assume there is no AJAX. I need to build the model from a database. If I use an LDM, on a postback Wicket calls to the database to rebuild the model before updating it with the new values. But if I don't use an LDM, Wicket will serialize the model in the PageMap. I would like to keep the model 'in memory' long enough to process the postback to avoid unecessary calls to the database, but release it when I have moved on to a different page. I thought of something like this... In the LDM @Override public Object load() { ...somehow get the session. if (session.getAttribute("PageAModel")!=null) { return (PageAModel)session.getAttribute("PageAModel"); } else { PageAModel pageAModel = ...build from database. session.setAttribute("PageAModel", PageAModel); return pageAModel; } } Then in the Page... @Override public void onSubmit() { PageAModel pageAModel=(PageAModel)session.getAttribute("PageAModel"); ...update the database with PageAModel pageAModel = (PageAModel)ldm.getObject(); ... //removes the model from session? session.setAttribute("PageAModel")=null; this.setResponsePage(...); } I suspect there is a better way to handle this. Can I avoid using an LDM, but somehow remove the model from the PageMap after leaving the page?
Wicket AutoComplete example does not work
I just looked at the wicket autocomplete example at http://www.wicket-library.com/wicket-examples/ajax/autocomplete?0 does not work in IE8 or Firefox. Brian Mulholland "For every complex problem, there is an answer that is clear, simple and wrong." --H.L. Mencken "Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly, and applying the wrong remedies." --Groucho Marx - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
jsessionid is not added to resources if cookies are disabled by the server
Hi Wicket fellows, When I configure the container (either Jetty or Tomcat) to not support cookies, I expect the jsessionid to be added to all resource links in the page. However, with Wicket 1.5.5 this isn't the case, i.e. all URLs are lacking the jsessionid. We are running our application in a setup with one active and one inactive Tomcat instance running in parallel behind a loadbalancer and an Apache. The requests are routed to the worker that is appended to the jsessionid, and if no worker can found it will be route to the currently active instance. This way you can keep sessions stable on a deactivated Tomcat if you deploy a new version to the inactive Tomcat and then switch it to be the active one. Now this leads to a quite random behavior when it comes to resources. Let's say Tomcat A is active and Tomcat B is inactive. If I then deploy a new version of the application to B and switch (i.e. A is inactive, B is active), the users still logged in on A will get the resources served by B because the jsessionid is missing and the requests are thus routed to B as the active instance. This causes strange side effects concerning Javascript, CSS, mounted images etc. In my opinion, this is a bug. I have found a few issues regarding this topic, e.g. https://issues.apache.org/jira/browse/WICKET-4334 and https://issues.apache.org/jira/browse/WICKET-4312. But even if WICKET-4312 seems to say that everything should work as before, I doubt that ;-) Could someone please verify that I'm not missing some configuration or anything? I created a quickstart do demonstrate the behavior - please see the attached file. The file jetty-web.xml tells Jetty to not support cookies, so it can be run with mvn jetty:run without any further configuration. By the way, I found a suggestion to use a custom IResourceCachingStrategy to append the jsessionid (or whatever) to URLs of resources in the archive of this list. Unfortunately, this doesn't work because the URL is encoded afterwards and the ; is turned into %3B :-( Any help is very much appreciated :-) Cheers, Michael jsessionid.tar.gz Description: GNU Zip compressed data - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Field with OnChangeAjaxBehavior Not updating.
Try calling form.clearInput() after you have updated the value of the models. I am having a bit of trouble making a required form field update from an ajax button. The field is marked required and has an OnChangeAjaxBehavior. The user deletes the contents of the field Presses an AjaxButton (todo some DB work which yields a new value) Ajax button sets a new value, The updated value is not pushed to the screen. I've got a quick start example. Tested with Wicket 1.5.5 All help is appreciated. HomePage.java package com.mycompany; import java.math.BigDecimal; import java.util.Locale; import org.apache.wicket.AttributeModifier; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.util.convert.IConverter; public class HomePage extends WebPage { /** * Simulate values from the DB */ private BigDecimal fromDBWith = BigDecimal.valueOf(500); private BigDecimal fromDBWithout = BigDecimal.valueOf(600); private BigDecimal withPrice = BigDecimal.valueOf(100); private BigDecimal withoutPrice = BigDecimal.valueOf(200); Model withModel = new Model() { @Override public BigDecimal getObject() { return withPrice; } @Override public void setObject(BigDecimal newVal) { withPrice = newVal; } }; Model withoutModel = new Model() { @Override public BigDecimal getObject() { return withoutPrice; } @Override public void setObject(BigDecimal newVal) { withoutPrice = newVal; } }; public HomePage(final PageParameters parameters) { Form form = new Form("someForm"); add(form); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); form.add(feedback); final MoneyTextField withTF = new MoneyTextField("withTF", withModel); withTF.setOutputMarkupId(true); // Required AND OnChangeAjaxBehavior means I cant update the form field from the button // when the field is empty. withTF.setRequired(true); withTF.add(new OnChangeAjaxBehavior() { @Override public void onUpdate(AjaxRequestTarget art) { System.out.println("In withTF onUpdate " + withPrice); } }); form.add(withTF); final MoneyTextField withoutTF = new MoneyTextField("withoutTF", withoutModel); withoutTF.setRequired(true); withoutTF.setOutputMarkupId(true); form.add(withoutTF); AjaxLink withBtn = new AjaxLink("withBtn") { @Override public void onClick(AjaxRequestTarget art) { System.out.println("In withBtn onClick " + withPrice); fromDBWith = fromDBWith.add(BigDecimal.ONE); withPrice = fromDBWith; art.add(withTF, feedback); } }; form.add(withBtn); AjaxLink withoutBtn = new AjaxLink("withoutBtn") { @Override public void onClick(AjaxRequestTarget art) { System.out.println("In withoutBtn onClick " + withoutPrice); fromDBWithout = fromDBWithout.add(BigDecimal.ONE); withoutPrice = fromDBWithout; art.add(withoutTF, feedback); } }; form.add(withoutBtn); } } /** * * @author peter */ class MoneyTextField extends TextField { public MoneyTextField(String id, IModel model) { super(id, model, BigDecimal.class); add(AttributeModifier.append("class", "money")); } @Override public String getInputType() { return "number"; } @Override public IConverter getConverter(Class ctype) { if (BigDecimal.class.isAssignableFrom(ctype)) { MoneyConverter mc = new MoneyConverter(false, false); IConverter res = (IConverter)mc; return res; //return mc.asInstanceOf>; } else { System.out.println("MoneyConverter NOT ASSIGNABLE FROM " + ctype); return super.getConverter(ctype); } } } /** * * @author peter */ class MoneyConverter implements IConverter { private Boolean blankWhenZero = false; private Boolean negativeShowCR = false; public MoneyConverter(Boolean blankWhenZero, Boolean negativeShowCR) { this.blankWhenZero = blankWhenZero; this.negativeShowCR = negativeShowCR; } @Override public BigDecimal convertToObject(String string, Locale locale) { //if (StringUtils.isBlank(string)) { if (string==null || string.length()==0) { //return BigDecimal.ZERO; return null; } return new BigDecimal(string); } @Override public String convertToString(BigDecimal o, Locale locale) { System.out.println("Mon
How To Catch Network Disconnection In Ajax Buttons
Hi, How do we catch network disconnection ? For example, I'm submitting using an indicatingajaxbutton, when the network is disconnected, the loading indicator disappears and the button is available again. Is there anyway that I can catch network disconnections in indicatingajaxbutton or any ajax button for that matter. I would like to post an alert warning to the client that he/she has been disconnected from the server. Is there anyway that I could insert something into this method? this is in wicket-ajax.js failure: function(message) { if (message != null) Wicket.Log.error("Wicket.Ajax.Call.failure: Error while parsing response: " + message); this.request.done(); this.failureHandler(); Wicket.Ajax.invokePostCallHandlers(); Wicket.Ajax.invokeFailureHandlers(); } Thanks! Carlo - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Field with OnChangeAjaxBehavior Not updating.
I am having a bit of trouble making a required form field update from an ajax button. The field is marked required and has an OnChangeAjaxBehavior. The user deletes the contents of the field Presses an AjaxButton (todo some DB work which yields a new value) Ajax button sets a new value, The updated value is not pushed to the screen. I've got a quick start example. Tested with Wicket 1.5.5 All help is appreciated. HomePage.java package com.mycompany; import java.math.BigDecimal; import java.util.Locale; import org.apache.wicket.AttributeModifier; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.util.convert.IConverter; public class HomePage extends WebPage { /** * Simulate values from the DB */ private BigDecimal fromDBWith = BigDecimal.valueOf(500); private BigDecimal fromDBWithout = BigDecimal.valueOf(600); private BigDecimal withPrice = BigDecimal.valueOf(100); private BigDecimal withoutPrice = BigDecimal.valueOf(200); Model withModel = new Model() { @Override public BigDecimal getObject() { return withPrice; } @Override public void setObject(BigDecimal newVal) { withPrice = newVal; } }; Model withoutModel = new Model() { @Override public BigDecimal getObject() { return withoutPrice; } @Override public void setObject(BigDecimal newVal) { withoutPrice = newVal; } }; public HomePage(final PageParameters parameters) { Form form = new Form("someForm"); add(form); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true); form.add(feedback); final MoneyTextField withTF = new MoneyTextField("withTF", withModel); withTF.setOutputMarkupId(true); // Required AND OnChangeAjaxBehavior means I cant update the form field from the button // when the field is empty. withTF.setRequired(true); withTF.add(new OnChangeAjaxBehavior() { @Override public void onUpdate(AjaxRequestTarget art) { System.out.println("In withTF onUpdate " + withPrice); } }); form.add(withTF); final MoneyTextField withoutTF = new MoneyTextField("withoutTF", withoutModel); withoutTF.setRequired(true); withoutTF.setOutputMarkupId(true); form.add(withoutTF); AjaxLink withBtn = new AjaxLink("withBtn") { @Override public void onClick(AjaxRequestTarget art) { System.out.println("In withBtn onClick " + withPrice); fromDBWith = fromDBWith.add(BigDecimal.ONE); withPrice = fromDBWith; art.add(withTF, feedback); } }; form.add(withBtn); AjaxLink withoutBtn = new AjaxLink("withoutBtn") { @Override public void onClick(AjaxRequestTarget art) { System.out.println("In withoutBtn onClick " + withoutPrice); fromDBWithout = fromDBWithout.add(BigDecimal.ONE); withoutPrice = fromDBWithout; art.add(withoutTF, feedback); } }; form.add(withoutBtn); } } /** * * @author peter */ class MoneyTextField extends TextField { public MoneyTextField(String id, IModel model) { super(id, model, BigDecimal.class); add(AttributeModifier.append("class", "money")); } @Override public String getInputType() { return "number"; } @Override public IConverter getConverter(Class ctype) { if (BigDecimal.class.isAssignableFrom(ctype)) { MoneyConverter mc = new MoneyConverter(false, false); IConverter res = (IConverter)mc; return res; //return mc.asInstanceOf>; } else { System.out.println("MoneyConverter NOT ASSIGNABLE FROM " + ctype); return super.getConverter(ctype); } } } /** * * @author peter */ class MoneyConverter implements IConverter { private Boolean blankWhenZero = false; private Boolean negativeShowCR = false; public MoneyConverter(Boolean blankWhenZero, Boolean negativeShowCR) { this.blankWhenZero = blankWhenZero; this.negativeShowCR = negativeShowCR; } @Override public BigDecimal convertToObject(String string, Locale locale) { //if (StringUtils.isBlank(string)) { if (string==null || string.length()==0) { //return BigDecimal.ZERO; return null; } return new BigDecimal(string); } @Override public String convertToString(BigDecimal o, Locale locale) { System.out.println("MoneyConverter o=" + o); if (o==null) { return ""; } if (blankWhenZero && o.compareTo(BigDecimal.ZERO)==0) { return ""; } if (negativeShowCR && o.compa