Re: Idiomatic way to reference shared images?
Hi John, Thank you for your answer. I was already aware of the idiomatic way for referencing packaged resources. It is a nice way for bundling images which are used within a package. My question was about images shared among multiple packages. Igor VaynBerg suggested adding a ContextImage which is what I was looking for. Another person (alankila) suggested images defined by ContextRelativeResource. Here is sample code: public class MyPage extends WebPage { public Contact() { ContextImage ci = new ContextImage(helpImage, images/help.gif); add(ci); } } Associated markup: img wicket:id=helpImage src=/ Of course the interesting part is that the help.gif file is located as a resource of my web-app and *not* part of WEB-INF/lib or WEB-INF/classes. HTH, John Krasnay wrote: On Wed, Oct 21, 2009 at 07:57:12PM +0200, Ceki Gulcu wrote: Hello, I am trying to defined shared images in a Wicket application. In my prokect, the image file help.gif is located under the src/main/java/com/foo/ folder of my project. I have created an empty class called Images. package com.foo; public class Images { } In the init() method of my web-application, I add help.gif as a shared resource: public class MyApplication extends WebApplication { @Override protected void init() { ... PackageResource pr = PackageResource.get(Images.class, help.gif); sharedResources.add(help.gif, pr); } } I normally don't need to do anything in my app's init() method for images. In markup, I attempt to access the images as wicket:link tdimg src=/resources/help.gif align=top//td /wicket:link You would use wicket:link when the image is in the same package as the markup. In this case, you would just put in img src=help.gif and Wicket will re-write the src attribute to the right value. This works well if you like to preview your markup in a browser. Since your images are (I think) in a different package, you should get rid of the wicket:link tag. (Actually, I think using a relative path to the right package in src might work with wicket:link, but I never do it that way. See below.) Unfortunately, this does not seem to work. However, the following markup works just fine but it's too cumbersome to write. wicket:link img src=resources/org.apache.wicket.Application/help.gif/ /wicket:link Reading page 229 of the Wicket in Action book, I would have thought that the /resources/help.gif reference would have worked. Quoting from the book: The resource is then available through a stable URL (/resources/discounts), independent of components. (page 229) What is the idiomatic way in Wicket to reference shared images? Here's my idiom. First, in the same package as my images, I create a class that extends ResourceReference: public class MyImage extends ResourceReference { public MyImage(String name) { super(MyImage.class, name); } } Then, I attach an Image component to the img tag: img wicket:id=smiley/ add(new Image(smiley, new MyImage(smiley.gif))); No code needed in Application.init(), and no wicket:link tags required. jk -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Idiomatic way to reference shared images?
Hello, I am trying to defined shared images in a Wicket application. In my prokect, the image file help.gif is located under the src/main/java/com/foo/ folder of my project. I have created an empty class called Images. package com.foo; public class Images { } In the init() method of my web-application, I add help.gif as a shared resource: public class MyApplication extends WebApplication { @Override protected void init() { ... PackageResource pr = PackageResource.get(Images.class, help.gif); sharedResources.add(help.gif, pr); } } In markup, I attempt to access the images as wicket:link tdimg src=/resources/help.gif align=top//td /wicket:link Unfortunately, this does not seem to work. However, the following markup works just fine but it's too cumbersome to write. wicket:link img src=resources/org.apache.wicket.Application/help.gif/ /wicket:link Reading page 229 of the Wicket in Action book, I would have thought that the /resources/help.gif reference would have worked. Quoting from the book: The resource is then available through a stable URL (/resources/discounts), independent of components. (page 229) What is the idiomatic way in Wicket to reference shared images? Many thanks in advance for your response, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Open Source projects using Wicket
Hi Martin, The System.out.println() calls are superfluous and will be removed in future releases of Mistletoe. They might be replaced by logger call if and when appropriate. Your comment about the manual is duly noted. I'll try to put together something more polished the next time. Cheers, Martin Grigorov wrote: It is little strange that _your_ (I emphasize here) software uses System.out.println() for logging instead of any of the logging frameworks you created ;-) From the manual on the page it is not very clear how to setup the whole thing. Probably I could manage it but it would be good to add step by step howto for the newbies. -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Open Source projects using Wicket
I started working with Wicket just a week ago in order to develop a junit extension for integration testing called Mistletoe. See http://mistletoe.qos.ch for details. Mistletoe's design imposes a strict separation between the data-model layer and the presentation layer. I am mentioning this because after designing the data-later, I started writing the presentation layer using Wicket. It's was a very pleasant experience. Wicket just clicked in my mind. By the way, wicket encouraged me to re-design my data-model slightly and I am quite happy with the results. *After* the wicket implementation, I did a simpler implementation of the presentation later using servlets (without any .jsp files). Given the experience of the wicket-based implementation, the servlet-based version was pretty straightforward, thanks to wicket's component-based architecture. For small projects, I now know for certain that it is possible to create a web-application quickly and cleanly. I do not have experience with larger projects. Dave B wrote: Hi, I'm in the process of evaluating Wicket (after an arduous JSF project, that has made us re-evaluate our web platform.) I've read Wicket in Action and whole bunch of blog and mailing list posts, done some proof-of-concept work and am now interested in reading source code from a project using Wicket, since I want to see Wicket in the wild. I know Artifactory uses Wicket, but their Subversion access instructions seem to be out of date. Does anyone know of an open source project using Wicket, so that I can peruse the source code? Many thanks, Dave -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Open Source projects using Wicket
When I wrote: it is possible to create a web-application quickly and cleanly, I meant to say that was possible to create a web-application quickly and cleanly *with* *Wicket*. Ceki Gulcu wrote: I started working with Wicket just a week ago in order to develop a junit extension for integration testing called Mistletoe. See http://mistletoe.qos.ch for details. Mistletoe's design imposes a strict separation between the data-model layer and the presentation layer. I am mentioning this because after designing the data-later, I started writing the presentation layer using Wicket. It's was a very pleasant experience. Wicket just clicked in my mind. By the way, wicket encouraged me to re-design my data-model slightly and I am quite happy with the results. *After* the wicket implementation, I did a simpler implementation of the presentation later using servlets (without any .jsp files). Given the experience of the wicket-based implementation, the servlet-based version was pretty straightforward, thanks to wicket's component-based architecture. For small projects, I now know for certain that it is possible to create a web-application quickly and cleanly. I do not have experience with larger projects. Dave B wrote: Hi, I'm in the process of evaluating Wicket (after an arduous JSF project, that has made us re-evaluate our web platform.) I've read Wicket in Action and whole bunch of blog and mailing list posts, done some proof-of-concept work and am now interested in reading source code from a project using Wicket, since I want to see Wicket in the wild. I know Artifactory uses Wicket, but their Subversion access instructions seem to be out of date. Does anyone know of an open source project using Wicket, so that I can peruse the source code? Many thanks, Dave -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SerializableChecker$WicketNotSerializableException:
Eelco Hillenius wrote: I've looked at it briefly. The main thing you need to keep in mind is that it unfortunately is a limitation of Wicket that you can't have references in Components that aren't serializable (unless you don't care about back button support and turn of the second level session cache, OR you plug in your own serialization support that doesn't need classes to be serializable). Thank you for your response. It is much appreciated. As I understand it, the back button problem is defined as the undesired triggering of a transaction subsequent to the user going back and resubmitting. For example, let page C be a purchase confirmation page and T be the thank you for your purchase page after the user confirms a certain purchase. The user confirms a purchase on C and the application sends T in response. If the user clicks on the back button and resubmits C, then the application should prevent a presumably unwanted re-purchase. Invalidating the cart when T is sent to the user is sufficient to solve this particular back-button problem. Again, as I understand it, instead of preserving state, the back-button problem is addressed by invalidating state. Surely, wicket is addressing a subtler back-button problem. In this case though, you don't really need those members, right? All the members are used in methods that are called during construction of the panel, so why not just pass them through those methods (or if you don't like that, make the members transient)? Since admittedly I don't actually understand the back-button problem, I don't see the consequences of eliminating references to unserializable members in my wicket components. I guess I'll have to experiment. Alternatively, in the case of this particular problem, I could construct a parallel serializable class hierarchy. While in the general case such an approach could be qualified as inelegant or even dumb, in this particular case it might the cheaper and the more elegant solution. Is there a wicket-example illustrating the back-button problem solved by wicket? I looked at http://wicketstuff.org/wicket14/stateless/ but its point was lost on me. Eelco On Fri, Oct 9, 2009 at 2:16 PM, Ceki Gulcu c...@qos.ch wrote: Eelco Hillenius wrote: Hi, It looks like GenericBaseModel has a reference to a JUnit Description? Maybe you can paste your GenericBaseModel class here? Fortunately, my application is open source. You can find its source code at http://github.com/ceki/mistletoe If you look at the DescriptionPanel class [1] you'll see that it essentially presents a junit.Description and a junit.Failure instance both of which are non-serializable. [1] http://tinyurl.com/yha75x8 If that's something you'll have a runtime you shouldn't ignore it if you want to support history (the backbutton). If it's just during testing, you can ignore it if you like. My application is a testing platform so I can't ignore junit nor testing. :-) -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SerializableChecker$WicketNotSerializableException:
Igor Vaynberg wrote: On Fri, Oct 9, 2009 at 1:41 PM, Ceki Gulcu c...@qos.ch wrote: Anyway, my application handles a complex tree-like structure, with almost all of the contents non-serializable and outside my control. I don't think I can use a Loadable Detachable Model, because loading the tree may take several minutes. you would use an LDM per node - the LDM should load the object represented by that node only, not the entire tree. does that make sense? LDM makes sense if you can detach data and then re-attach at a later time. In my case, I can't re-attach data without potentially paying a very severe penalty. (There is no datasource which can be queried for my data, as my data is runtime data. I'd need to re-run tests to re-acquire, which is pretty much nonsensical.) -igor -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SerializableChecker$WicketNotSerializableException:
Igor Vaynberg wrote: in other words, if you were building this app using jsps or servlets how would you carry over this data structure between requests? No, I actually would not carry the data between requests. When the page is requested, I would run my test suite to compute the results. Serving the test results from a previous test run is useless and is likely to be misleading.. Following Eelco's suggestion, I've set all the fields in my panel (DescriptionPanel) to transient. However, in one case the panel creates a ListView which references non-serializable data items. Thus I started creating a parallel and serializable data class hierarchy for presenting my results, which I am actually quite happy about. However, I also wish I knew a simpler solution if the same question arose in a different context where duplicating the class hierarchy would be inappropriate. -igor -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
SerializableChecker$WicketNotSerializableException:
Hello all, I have a working wicket application but I see the follwowing output on my console. 22:28:23.921 ERROR org.apache.wicket.util.lang.Objects - Error serializing object class \ ch.qos.mistletoe.wicket.Tree [object=[Page class = ch.qos.mistletoe.wicket.Tree, id = 4 version = 0]] org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: \ Unable to serialize class: org.junit.runner.Description Field hierarchy is: 4 [class=ch.qos.mistletoe.wicket.Tree, path=4] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=ch.qos.mistletoe.wicket.DescriptionPanel, path=4:node] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=ch.qos.mistletoe.wicket.DescriptionPanel$1, path=4:node:payload] java.lang.Object org.apache.wicket.Component.data [class=org.apache.wicket.model.util.WildcardListModel] private java.lang.Object org.apache.wicket.model.util.GenericBaseModel.object [class=java.util.ArrayList] private java.lang.Object org.apache.wicket.model.util.GenericBaseModel.object[write:1] [class=org.junit.runner.Description] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) [wicket-1.4.2.jar:1.4.2] at org.apache.wicket.util.io.SerializableChecker.access$500(SerializableChecker.java:63) [wicket-1.4.2.jar:1.4.2] at org.apache.wicket.util.io.SerializableChecker$1InterceptingObjectOutputStream.replaceObject(SerializableChecker.java:494) [wicket-1.4.2.jar:1.4.2] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1116) [na:1.6.0_05] By the way, if you are wondering where the [wicket-1.4.2.jar:1.4.2] suffix comes from, it is automatically generated by logback, log4j's successor.. Anyway, my application handles a complex tree-like structure, with almost all of the contents non-serializable and outside my control. I don't think I can use a Loadable Detachable Model, because loading the tree may take several minutes. Can I just ignore the serializable exception? If I don't what are the risks? -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SerializableChecker$WicketNotSerializableException:
Eelco Hillenius wrote: Hi, It looks like GenericBaseModel has a reference to a JUnit Description? Maybe you can paste your GenericBaseModel class here? Fortunately, my application is open source. You can find its source code at http://github.com/ceki/mistletoe If you look at the DescriptionPanel class [1] you'll see that it essentially presents a junit.Description and a junit.Failure instance both of which are non-serializable. [1] http://tinyurl.com/yha75x8 If that's something you'll have a runtime you shouldn't ignore it if you want to support history (the backbutton). If it's just during testing, you can ignore it if you like. My application is a testing platform so I can't ignore junit nor testing. :-) The backbutton, doh! Thanks. Eelco -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
self-recursive panel
Hello, I just succeeded to create a self-recursive panel displaying a tree-like structure with less than 40 lines of java code and 10 lines of HTML. I am including the code here in case someone is interested. == public class Node implements Serializable { String name; ListNode childrenList = new ArrayListNode(); Node(String name) { this.name = name; } public void add(Node child) { childrenList.add(child); } public String getName() { return name; } public ListNode getChildrenList() { return childrenList; } static Node getSampleNode() { Node nodeA = new Node(A); Node nodeA0 = new Node(A0); Node nodeA00 = new Node(A00); Node nodeA01 = new Node(A01); Node nodeA1 = new Node(A1); nodeA.add(nodeA0); nodeA.add(nodeA1); nodeA0.add(nodeA00); nodeA0.add(nodeA01); return nodeA; } } === Tree.java and Tree.html public class Tree extends WebPage { public Tree() { Node node = Node.getSampleNode(); NodePanel nodePanel = new NodePanel(, node, node); add(nodePanel); } } html xmlns=http://www.w3.org/1999/xhtml; head titleTree/title link rel=stylesheet href=style.css / /head body div wicket:id=node/div /body /html = NodePanel.hava and html == public class NodePanel extends Panel { public NodePanel(final String indent, String id, Node node) { super(id); add(new Label(name, indent+node.getName())); if (node.getChildrenList().size() == 0) { final WebMarkupContainer parent = new WebMarkupContainer(children); add(parent); parent.add(new EmptyPanel(node)); } else { add(new ListView(children, node.getChildrenList()) { @Override protected void populateItem(ListItem item) { Node childNode = (Node) item.getModelObject(); item.add(new NodePanel(indent+, node, childNode)); } }); } } } html xmlns:wicket wicket:panel p wicket:id=namename/p div wicket:id=children div wicket:id=node /div /div /wicket:panel /html HTH, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: self-recursive panel
I was not aware of the nested example in wicket-examples. Unfortunately, http://www.wicket-library.com/wicket-examples/nested/ barfs when I try to access it. Eelco Hillenius wrote: Yeah, that's like Wicket's nested example in wicket-examples. Eelco On Thu, Oct 8, 2009 at 12:27 PM, Ceki Gulcu c...@qos.ch wrote: Hello, I just succeeded to create a self-recursive panel displaying a tree-like structure with less than 40 lines of java code and 10 lines of HTML. I am including the code here in case someone is interested. == public class Node implements Serializable { String name; ListNode childrenList = new ArrayListNode(); Node(String name) { this.name = name; } public void add(Node child) { childrenList.add(child); } public String getName() { return name; } public ListNode getChildrenList() { return childrenList; } static Node getSampleNode() { Node nodeA = new Node(A); Node nodeA0 = new Node(A0); Node nodeA00 = new Node(A00); Node nodeA01 = new Node(A01); Node nodeA1 = new Node(A1); nodeA.add(nodeA0); nodeA.add(nodeA1); nodeA0.add(nodeA00); nodeA0.add(nodeA01); return nodeA; } } === Tree.java and Tree.html public class Tree extends WebPage { public Tree() { Node node = Node.getSampleNode(); NodePanel nodePanel = new NodePanel(, node, node); add(nodePanel); } } html xmlns=http://www.w3.org/1999/xhtml; head titleTree/title link rel=stylesheet href=style.css / /head body div wicket:id=node/div /body /html = NodePanel.hava and html == public class NodePanel extends Panel { public NodePanel(final String indent, String id, Node node) { super(id); add(new Label(name, indent+node.getName())); if (node.getChildrenList().size() == 0) { final WebMarkupContainer parent = new WebMarkupContainer(children); add(parent); parent.add(new EmptyPanel(node)); } else { add(new ListView(children, node.getChildrenList()) { @Override protected void populateItem(ListItem item) { Node childNode = (Node) item.getModelObject(); item.add(new NodePanel(indent+, node, childNode)); } }); } } } html xmlns:wicket wicket:panel p wicket:id=namename/p div wicket:id=children div wicket:id=node /div /div /wicket:panel /html HTH, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket problem with slf4j 1.4
Tauren Mills tauren at tauren.com writes: Thanks everyone for the help. I got it working with the following jars: log4j-1.2.15.jar slf4j-api-1.4.2.jar slf4j-log4j12-1.4.2.jar Is that what others are using? I had troubles while using logback, but I may not have used the right jars or got the configuration right. It seemed that Jetty was having troubles and throwing exceptions. What is the right combination of jars to use with logback? Tauren That looks correct for the SLF4J/log4j combo. For the SLF4J/logback combo, you would need slf4j-api-1.4.3.jar (1.4.2 is OK too) logback-core-0.9.8.jar logback-classic-0.9.8.jar I hope this helps, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]