Guice and Wicket: using SessionScoped injections
I have a working Wicket [v6] application with Guice [v3] - I have used dependency injection for repository operations right now and I want to expend it into using services that are session scoped (one per user's session). I have read through official documentation, various blog posts and questions here, but I am not sure if I am using the correct approach. I have two questions: 1. Do I use the correct way? 2. Do I need anything special to run TestNG tests on classes that rely on SessionScoped injections? My setup: web.xml: filter filter-nameguiceFilter/filter-name filter-classcom.google.inject.servlet.GuiceFilter/filter-class /filter filter-mapping filter-nameguiceFilter/filter-name url-pattern/*/url-pattern /filter-mapping listener listener-classcom.xxx.CustomServletConfig/listener-class MyApplication init: @Override protected void init() { super.init(); getResourceSettings().setResourcePollFrequency(null); getMarkupSettings().setStripWicketTags(true); getDebugSettings().setDevelopmentUtilitiesEnabled(true); GuiceComponentInjector injector = new GuiceComponentInjector(this, new WebModule(), new GuiceModule());; } CustomServletConfig: public class CustomServletConfig extends GuiceServletContextListener { @Override protected Injector getInjector() { return Guice.createInjector(new GuiceModule(), new WebModule()); } WebModule: public static class WebModule extends ServletModule { @Override protected void configureServlets() { bind(WebApplication.class).toProvider(WicketGuiceAppProvider.class).asEagerSingleton(); bind(IUserService.class).to(UserService.class).in(ServletScopes.SESSION); MapString, String params = new HashMapString, String(); params.put(WicketFilter.FILTER_MAPPING_PARAM, /*); filter(/*).through(WicketGuiceFilter.class, params); } } In an example page I have: @Inject IUserService userService ... userService.doSomething At userService.doSomething during unit test I am getting Guice OutOfScopeException, pointing to my bindings in ServletModule: Error in custom provider, com.google.inject.OutOfScopeException?: Cannot access scoped object. Either we are not currently inside an HTTP Servlet request, or you may have forgotten to apply com.google.inject.servlet.GuiceFilter? as a servlet filter for this request. Is my configuration ok and I need to run unit tests differently (I am simply launching my application with WicketTester), or is my design faulty? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Guice-and-Wicket-using-SessionScoped-injections-tp4662027.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
PropertyModel not refreshing
Hi, I have a form with labels that use PropertyModel. They work fine when I test them locally - when I click on submit button I get proper refreshed values in labels. But when I deploy my app it does not work, I still get old values. Where can be the problem? I am using Wicket 1.4.17 and deploying on Google AppEngine. My code: FormString buildHousesForm = new FormString(buildHousesForm, new ModelString()) ... ... add(new Label(houses_amount, new PropertyModel(MySession.get().getUser(), village))); ... ... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/PropertyModel-not-refreshing-tp3877389p3877389.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: PropertyModel not refreshing
Why would there be a difference between local and deployed versions? And won't it negatively affect performance? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/PropertyModel-not-refreshing-tp3877389p3877621.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: PropertyModel not refreshing
Thanks, I will give it a try :) -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/PropertyModel-not-refreshing-tp3877389p3877636.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
Authentication and sessions - the right way?
Hi, I have a problem with designing authentication and session properly. I asked for help some time ago, but I was not able to fix the problem. I have a standard situation - I have an app that has bunch of pages and only main page with login form should be accessible for everyone. Everything else should be available after you log in. And some technical pages that should be accessible for admins only. So I want AuthenticatedApplication and AuthenticatedWebSession. I set main page with login form in Application as the page that does not need authentication. Then someone enters proper credentials and I set in Session username [key] and whole User entity (transient) with proper role. It all works fine on my computer, but when I deploy it, it stops working. Session gets detached on the way and I cannot fetche the data to my models. Yes, I keep user data in my session, I could do it with datastore queries, but session is better solution on AppEngine. And problem would still be the same pretty much. There are 2 problems, which I don't really understand: 1. Session gets detached - where is it explained when and why it happens? How should I properly initialise it? I thought that making MySession.get().(...) would be enough... When user logs in, I do MySession.get().setUser(...). Then user gets redirected to main app page, where there are labels to display data (MySession.get().getUser().getValueX(). Where is my mistake? 2. How to fetch data from Guice in Session? I have a RepositoryUser Inject, but when it is used in Session it throws nullpointer exception. Should I have it in session at all? I guess repopulating user data like that is not the best idea, I should probably just redirect him to login page again, if session somehow losses data. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Authentication-and-sessions-the-right-way-tp3866840p3866840.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: Authentication and sessions - the right way?
But would it be possible to store User data in the session without having to fetch it from datastore on every request? My users don't interact with each other and they operate only on their own data. So it'd be most efficient to store User data in the session and interact with db only when some data is changed. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Authentication-and-sessions-the-right-way-tp3866840p3866866.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: Authentication and sessions - the right way?
So it's normal that I lose User data when I move from login to main page and I will have to fetch it from db quite often. When will it happen? I have users browsing around my app, doing most often nothing. Plenty of labels with gets. Will browsing like that trigger fetching user data from db? Or will that data be served from cache? Whenever anything changes data will be stored in db and page will reload. Will it fetch data from db again or serve them from cache? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Authentication-and-sessions-the-right-way-tp3866840p3866875.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: Authentication and sessions - the right way?
Marco: And it works without problems? There is no issue with user trying to log from 2 browser on same time, trying to cheat the system? I am just wondering if there is any risk of that. How does your code look then in session and how do you fetch your data? Martin: I was trying to save on costs, where on AppEngine you are billed for every DB query, while memcache is pretty much free. Is it really hard to keep session data in sync? Only that user can modify his data. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Authentication-and-sessions-the-right-way-tp3866840p3866906.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: Users, sessions, data...
Well, my app is a game which you could call Excel, but in fantasy settings :) Modifying lots of tables and simple calculations, lots of them. Some people call that building, attacking, spellcasting... I have most of stuff atm in User entity, over 100 variables, some of them ArrayLists and HashMaps. Persistence with JDO and Guice to make things nicer. Right now I am putting whole User into session, then retrieving data from it. When user modified smth with a form, it would persist whole User to the db. Most of the time there is not much interaction - user walks around the app and looks at numbers, getting them every time from db and not from session seems ineffective. Of course consistency and workability are more important :) Smooth experience for users and no chance for bugs [ISE, blank pages, other user's data, out of order persists] is the most important thing here. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Users-sessions-data-tp3598626p3602085.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
Users, sessions, data...
Hi, My last attempts to fix my session and advices here made me thinking if my approach is good. So I'm curious - how do you handle users and their data? In my case I have session, when user logs in entire entity gets loaded into session. Later I get user data from that session and when he changes anything it gets persisted to db. There is no direct interaction between user and only that user can access his data. What is your approach? :) -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Users-sessions-data-tp3598626p3598626.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: Users, sessions, data...
But what are benefits of small session really? With entire user in session I can skip getting data from db and serve data faster... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Users-sessions-data-tp3598626p3598945.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: Users, sessions, data...
Well, I'm hosting it on GAE and with new pricing model I have to worry about instances, not memcache or things like that. And I don't have to do load balancing. To be sure that data does not get lost between instances [which could happen probably with big traffic and longer inactivity from user] I can just have a check in getUser() method which could reload data from db if needed. I wonder if enabling multithreading could cause problems... Loading user every time from db would be probably too slow and could spin up too many instances due to that. Right now it looks like I can get data fast from session and do a persist in 15-30ms. Add time for all calculations of course. Numbers may be different with more users though. Anyway, I'm fairly new to programming and Wicket, so I don't know what's fast or reasonable. Just trying to figure if I'm going in good direction before it's too late to change it. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Users-sessions-data-tp3598626p3599401.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
Rounding values for display
Hi, I have labels showing data that is in Double format, but I don't need so much precision in UI. Can I easily make my page round those values [down] and display just numbers without fraction? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Rounding-values-for-display-tp3584858p3584858.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
Major session problem [GAE]
Hi, I have really serious problems with my sessions - or rather getting and displaying data with it. It works great when tested locally, but when deployed to GAE it acts weird. In bad way. I have no idea if it's wicket or GAE issue, but maybe I can get some hints here. Problem is that: - it quite often fails to load data, so when user logs it it shows blank pages, without any data, that should com from session [MySession.loggedInUser.get...] - on very rare occasions it can show old values, that were changed long time ago, some residue must be left over somewhere and is not cleaned and somehow it can switch between - and there was a case when one user could see data from other user [so sessions switched?] Of course situations 23 can never happen. Situation 1 neither - but maybe it can be solved by some check and reload of data? Some code to illustrate: MySession: public class MySession extends WebSession { public MySession(Request request) { super(request); } public boolean isAuthenticated() { return (loggedInUser != null); } public static User loggedInUser; public User getLoggedInUser() { return loggedInUser; } public void setLoggedInUser(User loggedInUser) { this.loggedInUser = loggedInUser; } } In Login: ((MySession) MySession.get()).setLoggedInUser(user); Later data is accessed by MySession.loggedInUser.[getters/setters here] and persisted to datastore when anything changes. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Major-session-problem-GAE-tp3584894p3584894.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: Rounding values for display
So I can use one converter in Application for all my Labels? That would be great :) P.S. I am really amazed how fast you can get responses here. It's hard not to love Wicket. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Rounding-values-for-display-tp3584858p3584914.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: Major session problem [GAE]
Yeah, no idea why Static is there, must be some leftover from early code. It's good to have someone else take a look at your code and point the obvious :) I will check if it solves my problems. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Major-session-problem-GAE-tp3584894p3585007.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: Major session problem [GAE]
norckon: Getting whole entity is good in my case. User can modify only his data and no one else can even access or see it. It speeds up things too. Anyway, how do you invoke the rest? Without static you of course get non-static method cannot be referenced from a static context compilation error. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Major-session-problem-GAE-tp3584894p3585460.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: Major session problem [GAE]
So... MySession.get().getUser().getLand() to properly get a value from session? Looks like it could have some performance issues, or does it just look so scary? :) -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Major-session-problem-GAE-tp3584894p3585657.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
DataView the easy way?
Hi, I am trying to make my first DataView and I found an example that does what I want. It's quite confusing though - it takes like 15 pages and classes to do it and I cannot decipher it. http://wicketstuff.org/wicket14/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.SimplePage http://wicketstuff.org/wicket14/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.SimplePage So, any ideas how to do it fast, just on one page? I have a HashTable with ArrayLists [HashTablelt;Integer, ArrayListlt;Longgt;] that I want to display. Of course I don't know how many rows I will have, that's why I want DataView. I want to display 3 first data from the ArrayList in the map and I want to be able to select rows [so I can delete them by int id]. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3578760.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
Links blocked when I enter page
Hi, I have rather weird problem. I have a page with navigation panel [mostly bookmarkable links]. It works fine on all but one. On that one page when I enter it, some of my navigation links get blocked - 2 out of 5. Any idea what may be causing it? They turn fine when I click on submit button on that page [it turns visibility of another button to true - can there be some weird bug with it?]. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Links-blocked-when-I-enter-page-tp3578762p3578762.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: Links blocked when I enter page
Well, they don't do it in my case. Maybe because they are in panel... Anyway, I wouldn't have problem with that. It's that 2 other links are blocked, those that lead to other pages. I don't have problem like that on other pages and only thing here that is different is that additional submit button with changing visibility. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Links-blocked-when-I-enter-page-tp3578762p3578815.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: DataView the easy way?
Right :) So I want to start with something like: add(new DataViewExpedition(expedition, MySession.loggedInUser.colonisations) { }); I am confused how to implement populateItem though... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3579124.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: DataView the easy way?
Do I need to do anything special? Will it automatically go through all rows of my Map? When my map is HashMaplt;Integer,ArrayListgt; then Expedition will be my ArrayList or whole row, together with int id? I could probably use just a list of ArrayLists if it'd be easier... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3579147.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: DataView the easy way?
Ok, I changed it to ArrayListlt;ArrayListlt;Longgt;, but I still don't get how to use populateItem... Even testing just that add(new DataViewExpedition(expedition, MySession.loggedInUser.colonisations) { }); Results in: internal error; cannot instantiate org. apache.wicket.markup.repeater.data.DateView.init at org.apache.wicket.markup.repeater.data.DAtaViewExpedition to () -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3579173.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: Links blocked when I enter page
Nope, panel is separate. There should be no connection... I will rather paste some code, maybe it will give a hint... add(new FeedbackPanel(errorMsg)); // starting form private boolean col_approval = false; Button calculateColCost = new Button(calculateColCost) { @Override public void onSubmit() { //some methods, one with sendExpedition.setVisible(false); else { sendExpedition.setVisible(true); //... Button sendExpedition = new Button(sendExpedition) { //... }; { add(sendExpedition); sendExpedition.setVisible(col_approval); }; }; //add form I don't see anything special here, so no idea how it could make result like that... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Links-blocked-when-I-enter-page-tp3578762p3579180.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: DataView the easy way?
I almost have it... I have my ArrayList of lists, so I guess my code should look smth like that: ArrayListlt;ArrayListlt;Longgt; colonisations = MySession.loggedInUser.colonisations; add(new DataView(expeditionsView, new ListDataProvider(colonisations)) { @Override protected void populateItem(final Item item) { ArrayList expedition = (ArrayList)item.getModelObject(); // item represents the current row-component item.add(new Label(title, expedition.get(0))); item.add(new Label(price, expedition.get(1))); } }); I must be doing some fundamental mistake here, as it can't work. It throws cannot find symbol: symbol constructor Label at both item.add lines -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3579270.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: DataView the easy way?
Thanks a lot, it works :) -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataView-the-easy-way-tp3578760p3579384.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: ArrayList, Label and Model
Nope, still same error: org.apache.wicket.RequestCycle logRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost org.apache.wicket.WicketRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost { System.out.println(Values: + house_cost.get(0)+ + house_cost.get(1)+ + house_cost.get(2)+ + house_cost.get(3)+ + house_cost.get(4) ); } This works and gives proper values. I'd be surprised if Wicket required smth special just to display that... On Sat, Oct 23, 2010 at 7:08 AM, Ernesto Reinaldo Barreiro-4 [via Apache Wicket] ml-node+3008166-1025517113-152...@n4.nabble.comml-node%2b3008166-1025517113-152...@n4.nabble.com wrote: Can you try PropertyModel(this, house_cost[4])? Ernesto On Fri, Oct 22, 2010 at 10:39 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=3008166i=0 wrote: Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList and display it with a Label? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.htmlhttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3008166i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3008166i=2 - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3008166i=3 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3008166i=4 -- View message @ http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3008166.html To unsubscribe from ArrayList, Label and Model, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=3007849code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwzMDA3ODQ5fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3008269.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: ArrayList, Label and Model
Ha! Good suggestion, I should have looked at this earlier. I guess I need better understanding of how things work. this in my situation referred just to a form, so it could not find the data required. When I cloned the ArrayList again in the Form, it works. But that's not exactly good thing to do, what should I use instead of this to get the data properly, without repeating it? Building.class does not work [same error with get method]. I just want to access and display data that is outside form... Right now it looks like that: public class Building extends EconPage{ public Building() { int nation = MySession.loggedInUser.getNation(); ArrayListDouble base_costs = new ArrayListDouble(); final ArrayListDouble house_cost = new ArrayListDouble(5); ... add(new FeedbackPanel(errorMsg)); FormString buildHousesForm = new FormString(buildHousesForm, new ModelString()) { private TextFieldLong build_houses = new TextFieldLong(build_houses, new ModelLong()); { ... add(new Label(houses_infracost, new PropertyModel(this, houses_cost.0))); ... add(build_houses); } }; add(buildHousesForm); } } On Sat, Oct 23, 2010 at 2:13 PM, Sven Meier [via Apache Wicket] ml-node+3008353-1436517199-152...@n4.nabble.comml-node%2b3008353-1436517199-152...@n4.nabble.com wrote: The PropertyModel is having problems with house_cost. What is this in your example? Is house_cost a member variable of your this? Sven On 10/23/2010 11:35 AM, Zeldor wrote: Nope, still same error: org.apache.wicket.RequestCycle logRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost org.apache.wicket.WicketRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost { System.out.println(Values: + house_cost.get(0)+ + house_cost.get(1)+ + house_cost.get(2)+ + house_cost.get(3)+ + house_cost.get(4) ); } This works and gives proper values. I'd be surprised if Wicket required smth special just to display that... On Sat, Oct 23, 2010 at 7:08 AM, Ernesto Reinaldo Barreiro-4 [via Apache Wicket][hidden email]http://user/SendEmail.jtp?type=nodenode=3008353i=0 [hidden email] http://user/SendEmail.jtp?type=nodenode=3008353i=1 wrote: Can you try PropertyModel(this, house_cost[4])? Ernesto On Fri, Oct 22, 2010 at 10:39 PM, Zeldor[hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=0 wrote: Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList and display it with a Label? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.htmlhttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=t http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=thttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=tby-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=1 For additional commands, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=2 - To unsubscribe, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=3 For additional commands, e-mail: [hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=4 -- View message @ http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3008166.htmlhttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3008166.html?by-user=t To unsubscribe from ArrayList, Label and Model, click here http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=3007849code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwzMDA3ODQ5fC0xMTUwMjA4NDM=http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=3007849code
Re: ArrayList, Label and Model
It's a table with lots of data to display, with a mixture of plain text, data from session and from arrays, so it'd be rather hard to solve it with ListView. So my only problem is how to point the Label to data that is outside Form. On Sat, Oct 23, 2010 at 5:03 PM, James Carman [via Apache Wicket] ml-node+3008486-1151478827-152...@n4.nabble.comml-node%2b3008486-1151478827-152...@n4.nabble.com wrote: The PropertyModel takes a root object on which it will evaluate the expression. So, you have to make sure the property is traversable from the root object. Most likely, you'd be better off using a ListView for your situation if you're trying to show all the items in the list. On Sat, Oct 23, 2010 at 10:59 AM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=3008486i=0 wrote: Ha! Good suggestion, I should have looked at this earlier. I guess I need better understanding of how things work. this in my situation referred just to a form, so it could not find the data required. When I cloned the ArrayList again in the Form, it works. But that's not exactly good thing to do, what should I use instead of this to get the data properly, without repeating it? Building.class does not work [same error with get method]. I just want to access and display data that is outside form... Right now it looks like that: public class Building extends EconPage{ public Building() { int nation = MySession.loggedInUser.getNation(); ArrayListDouble base_costs = new ArrayListDouble(); final ArrayListDouble house_cost = new ArrayListDouble(5); ... add(new FeedbackPanel(errorMsg)); FormString buildHousesForm = new FormString(buildHousesForm, new ModelString()) { private TextFieldLong build_houses = new TextFieldLong(build_houses, new ModelLong()); { ... add(new Label(houses_infracost, new PropertyModel(this, houses_cost.0))); ... add(build_houses); } }; add(buildHousesForm); } } On Sat, Oct 23, 2010 at 2:13 PM, Sven Meier [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=1[hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=2 wrote: The PropertyModel is having problems with house_cost. What is this in your example? Is house_cost a member variable of your this? Sven On 10/23/2010 11:35 AM, Zeldor wrote: Nope, still same error: org.apache.wicket.RequestCycle logRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost org.apache.wicket.WicketRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost { System.out.println(Values: + house_cost.get(0)+ + house_cost.get(1)+ + house_cost.get(2)+ + house_cost.get(3)+ + house_cost.get(4) ); } This works and gives proper values. I'd be surprised if Wicket required smth special just to display that... On Sat, Oct 23, 2010 at 7:08 AM, Ernesto Reinaldo Barreiro-4 [via Apache Wicket][hidden email] http://user/SendEmail.jtp?type=nodenode=3008353i=0 [hidden email] http://user/SendEmail.jtp?type=nodenode=3008353i=1 wrote: Can you try PropertyModel(this, house_cost[4])? Ernesto On Fri, Oct 22, 2010 at 10:39 PM, Zeldor[hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=0 wrote: Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList and display it with a Label? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.htmlhttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=t http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=thttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=tby-user=t http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.html?by-user=thttp://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849
Re: ArrayList, Label and Model
Any good examples? :) It'd be certainly better to have some repeaters instead of so many single Label declarations. On Sat, Oct 23, 2010 at 5:32 PM, James Carman [via Apache Wicket] ml-node+3008524-1615548235-152...@n4.nabble.comml-node%2b3008524-1615548235-152...@n4.nabble.com wrote: You'd be surprised what you can do with a table. On Sat, Oct 23, 2010 at 11:09 AM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=3008524i=0 wrote: It's a table with lots of data to display, with a mixture of plain text, data from session and from arrays, so it'd be rather hard to solve it with ListView. So my only problem is how to point the Label to data that is outside Form. On Sat, Oct 23, 2010 at 5:03 PM, James Carman [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008524i=1[hidden email] http://user/SendEmail.jtp?type=nodenode=3008524i=2 wrote: The PropertyModel takes a root object on which it will evaluate the expression. So, you have to make sure the property is traversable from the root object. Most likely, you'd be better off using a ListView for your situation if you're trying to show all the items in the list. On Sat, Oct 23, 2010 at 10:59 AM, Zeldor [hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=0 wrote: Ha! Good suggestion, I should have looked at this earlier. I guess I need better understanding of how things work. this in my situation referred just to a form, so it could not find the data required. When I cloned the ArrayList again in the Form, it works. But that's not exactly good thing to do, what should I use instead of this to get the data properly, without repeating it? Building.class does not work [same error with get method]. I just want to access and display data that is outside form... Right now it looks like that: public class Building extends EconPage{ public Building() { int nation = MySession.loggedInUser.getNation(); ArrayListDouble base_costs = new ArrayListDouble(); final ArrayListDouble house_cost = new ArrayListDouble(5); ... add(new FeedbackPanel(errorMsg)); FormString buildHousesForm = new FormString(buildHousesForm, new ModelString()) { private TextFieldLong build_houses = new TextFieldLong(build_houses, new ModelLong()); { ... add(new Label(houses_infracost, new PropertyModel(this, houses_cost.0))); ... add(build_houses); } }; add(buildHousesForm); } } On Sat, Oct 23, 2010 at 2:13 PM, Sven Meier [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=1[hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=2 wrote: The PropertyModel is having problems with house_cost. What is this in your example? Is house_cost a member variable of your this? Sven On 10/23/2010 11:35 AM, Zeldor wrote: Nope, still same error: org.apache.wicket.RequestCycle logRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost org.apache.wicket.WicketRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost { System.out.println(Values: + house_cost.get(0)+ + house_cost.get(1)+ + house_cost.get(2)+ + house_cost.get(3)+ + house_cost.get(4) ); } This works and gives proper values. I'd be surprised if Wicket required smth special just to display that... On Sat, Oct 23, 2010 at 7:08 AM, Ernesto Reinaldo Barreiro-4 [via Apache Wicket][hidden email] http://user/SendEmail.jtp?type=nodenode=3008353i=0 [hidden email] http://user/SendEmail.jtp?type=nodenode=3008353i=1 wrote: Can you try PropertyModel(this, house_cost[4])? Ernesto On Fri, Oct 22, 2010 at 10:39 PM, Zeldor[hidden email] http://user/SendEmail.jtp?type=nodenode=3008166i=0 wrote: Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList
Re: ArrayList, Label and Model
Right, I am certainly going to upgrade my app to use as much Ajax as possible, to make it more efficient :) I am still curious what I should use isntead of this to display data not in Form. On Sat, Oct 23, 2010 at 6:19 PM, James Carman [via Apache Wicket] ml-node+3008574-339171290-152...@n4.nabble.comml-node%2b3008574-339171290-152...@n4.nabble.com wrote: Here's an example of setting up an AjaxFallbackDefaultDataTable: http://svn.carmanconsulting.com/public/wicket-advanced/trunk/src/main/java/com/carmanconsulting/wicket/advanced/web/story3/page/Home.java It's simple, but it gives you the idea. You'll probably need to figure out how to do your own custom column, unless you use a list of more complex objects (think DTOs) containing the properties you want to display. This might be the easiest way to do what you want. On Sat, Oct 23, 2010 at 12:10 PM, James Carman [hidden email] http://user/SendEmail.jtp?type=nodenode=3008574i=0 wrote: Well, I'd start with a ListView if you really think it's that difficult. It should be easy to do, though. You'd just take one set of those labels and put it inside the populateItem() method. If you want headers, sorting, etc., then you might want to upgrade to a DefaultDataTable (or its ajax-based subclass). On Sat, Oct 23, 2010 at 11:51 AM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=3008574i=1 wrote: Any good examples? :) It'd be certainly better to have some repeaters instead of so many single Label declarations. On Sat, Oct 23, 2010 at 5:32 PM, James Carman [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008574i=2[hidden email] http://user/SendEmail.jtp?type=nodenode=3008574i=3 wrote: You'd be surprised what you can do with a table. On Sat, Oct 23, 2010 at 11:09 AM, Zeldor [hidden email] http://user/SendEmail.jtp?type=nodenode=3008524i=0 wrote: It's a table with lots of data to display, with a mixture of plain text, data from session and from arrays, so it'd be rather hard to solve it with ListView. So my only problem is how to point the Label to data that is outside Form. On Sat, Oct 23, 2010 at 5:03 PM, James Carman [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008524i=1[hidden email] http://user/SendEmail.jtp?type=nodenode=3008524i=2 wrote: The PropertyModel takes a root object on which it will evaluate the expression. So, you have to make sure the property is traversable from the root object. Most likely, you'd be better off using a ListView for your situation if you're trying to show all the items in the list. On Sat, Oct 23, 2010 at 10:59 AM, Zeldor [hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=0 wrote: Ha! Good suggestion, I should have looked at this earlier. I guess I need better understanding of how things work. this in my situation referred just to a form, so it could not find the data required. When I cloned the ArrayList again in the Form, it works. But that's not exactly good thing to do, what should I use instead of this to get the data properly, without repeating it? Building.class does not work [same error with get method]. I just want to access and display data that is outside form... Right now it looks like that: public class Building extends EconPage{ public Building() { int nation = MySession.loggedInUser.getNation(); ArrayListDouble base_costs = new ArrayListDouble(); final ArrayListDouble house_cost = new ArrayListDouble(5); ... add(new FeedbackPanel(errorMsg)); FormString buildHousesForm = new FormString(buildHousesForm, new ModelString()) { private TextFieldLong build_houses = new TextFieldLong(build_houses, new ModelLong()); { ... add(new Label(houses_infracost, new PropertyModel(this, houses_cost.0))); ... add(build_houses); } }; add(buildHousesForm); } } On Sat, Oct 23, 2010 at 2:13 PM, Sven Meier [via Apache Wicket] [hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=1[hidden email] http://user/SendEmail.jtp?type=nodenode=3008486i=2 wrote: The PropertyModel is having problems with house_cost. What is this in your example? Is house_cost a member variable of your this? Sven On 10/23/2010 11:35 AM, Zeldor wrote: Nope, still same error: org.apache.wicket.RequestCycle logRuntimeException: no get method defined for class: class com.myproject.economy.Building$1 expression: house_cost org.apache.wicket.WicketRuntimeException: no get method defined for class: class
ArrayList, Label and Model
Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList and display it with a Label? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007849.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: ArrayList, Label and Model
Nope, it still does not work, so it must be something else. I have tried searching here, but I have only found people using ArrayList as whole, for dropdownmenus etc, not pointing to one specific data. It should be quite simple... On Fri, Oct 22, 2010 at 11:17 PM, Sven Meier [via Apache Wicket] ml-node+3007899-704217102-152...@n4.nabble.comml-node%2b3007899-704217102-152...@n4.nabble.com wrote: Hi, according to the API PropertyModel(this, house_cost.4) should work: http://wicket.apache.org/apidocs/1.4/org/apache/wicket/util/lang/PropertyResolver.html Sven Am 22.10.2010 22:39, schrieb Zeldor: Hi, I am trying to make an ArrayList, populate it and then display them [and do other stuff later, but I did not get so far]. It does not work though, so what I am missing? My code looks like that: ... ArrayListDouble house_cost = new ArrayListDouble(5); ... [adding some data here] [form] add(new Label(houses_goldcost, new PropertyModel(this, house_cost.get(4; ... I am of course getting the generic no get method defined for class error, so I must be doing something wrong. What is the correct way to get just one cell from ArrayList and display it with a Label? - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3007899i=0 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=3007899i=1 -- View message @ http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007899.html To unsubscribe from ArrayList, Label and Model, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=3007849code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwzMDA3ODQ5fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/ArrayList-Label-and-Model-tp3007849p3007950.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
MinimumValidator and Long problem
I have TextField that should take Long value, but on submit it does not really work... org.apache.wicket.RequestCycle logRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 org.apache.wicket.WicketRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 My code looks like that: public Work() { add(new FeedbackPanel(errorMsg)); FormString workForm = new FormString(workForm, new ModelString()) { private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); ... { ... add(hire_worker_1.add(new MinimumValidator(0)) .setType(Long.class)); ... } @Override public void onSubmit() { long hiring_worker_1 = hire_worker_1.getModelObject(); ... } }; add(workForm); } Eclipse does like new MinimumValidatorLong(0), so what's the solution for my problem? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.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: MinimumValidator and Long problem
Changing it to : private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); { hire_worker_1.setType(Long.class); } Does not change anything. And is it normal that Eclipse does not let me add anything without enclosing in { }? BTW, is there any easy way to convert nulls to 0 when you submit empty TextFields? On Tue, Oct 12, 2010 at 11:31 PM, jer...@wickettraining.com [via Apache Wicket] ml-node+2992772-1878280583-152...@n4.nabble.comml-node%2b2992772-1878280583-152...@n4.nabble.com wrote: Since your model doesn't actually know what type of field it is operating on (like PropertyModel does), you need to call setType(Long.class) on your text field. On Tue, Oct 12, 2010 at 1:23 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=0 wrote: I have TextField that should take Long value, but on submit it does not really work... org.apache.wicket.RequestCycle logRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 org.apache.wicket.WicketRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 My code looks like that: public Work() { add(new FeedbackPanel(errorMsg)); FormString workForm = new FormString(workForm, new ModelString()) { private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); ... { ... add(hire_worker_1.add(new MinimumValidator(0)) .setType(Long.class)); ... } @Override public void onSubmit() { long hiring_worker_1 = hire_worker_1.getModelObject(); ... } }; add(workForm); } Eclipse does like new MinimumValidatorLong(0), so what's the solution for my problem? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.htmlhttp://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=2 -- Jeremy Thomerson http://www.wickettraining.com http://www.wickettraining.com?by-user=t -- View message @ http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992772.html To unsubscribe from MinimumValidator and Long problem, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2992468code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTkyNDY4fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992825.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: MinimumValidator and Long problem
I have nothing else really, just same more of same stuff, only a Form with Labels, TextFields and submit method. Anyway, deprecated NumberValidator.minimum(0) method works without any problems, are there any disadvantages of using that? On Wed, Oct 13, 2010 at 12:43 AM, jer...@wickettraining.com [via Apache Wicket] ml-node+2992859-520586739-152...@n4.nabble.comml-node%2b2992859-520586739-152...@n4.nabble.com wrote: On Tue, Oct 12, 2010 at 5:36 PM, Igor Vaynberg [hidden email]http://user/SendEmail.jtp?type=nodenode=2992859i=0wrote: its not a syntax problem. you cant have code outside a method unless its in a static {} block. To me, putting code outside a method *is* a syntax problem, typically caused by inexperience with anonymous inner classes, leading to not enough, or too many } -- Jeremy Thomerson http://www.wickettraining.com http://www.wickettraining.com?by-user=t -- View message @ http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992859.html To unsubscribe from MinimumValidator and Long problem, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2992468code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTkyNDY4fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2993027.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: RadioChoice - what's wrong?
So maybe someone could just show me working RadioChoice code with OnSubmit part? Just how to properly display it and grab data from it :) That should solve the problem, as I would compare and see what I'm doing wrong. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2970217.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: RadioChoice - what's wrong?
It does! Thanks a lot! I knew it was something stupid and trivial. Huh, but it should not cause that still - I was defining TextFields in same way and then again to add parameters and it went fine. On Sun, Oct 10, 2010 at 7:11 PM, Andrea Del Bene [via Apache Wicket] ml-node+2970427-965616561-152...@n4.nabble.comml-node%2b2970427-965616561-152...@n4.nabble.com wrote: Hello Zeldor, I've red your code and it seems that you define variable rc two times: the first time as form private field and the second time just below between braces. When onSubmit method calls rc.getModelObject() it uses private field rc which was not initialized and so triggers a NullPointerException. Try to remove the second type definition RadioChoiceString and it should work. public class Registration extends WebPage { public Registration() { add(new FeedbackPanel(errorMsg)); //New user registration form FormString regForm = new FormString(registrationForm,new ModelString()) { static final ListString NUMBERS = Arrays.asList(new String[] { 1, 2, 3 }); private RadioChoiceString rc; { RadioChoiceString rc = new RadioChoiceString(numberRadioChoice, new ModelString(),NUMBERS).setSuffix(); add(rc.setRequired(true)); } @Override public void onSubmit() { String _numbers = rc.getModelObject(); System.out.println(_numbers); } }; add(regForm); } } - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2970427i=0 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2970427i=1 -- View message @ http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2970427.html To unsubscribe from RadioChoice - what's wrong?, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2967576code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTY3NTc2fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2970465.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: RadioChoice - what's wrong?
186 is System.out.println(_numbers); -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967903.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: RadioChoice - what's wrong?
Well, _numbers is null :) That's why I wonder what's wrong with getting the ObjectModel - I must be doing smth wrong there :) On Fri, Oct 8, 2010 at 8:43 AM, Igor Vaynberg-2 [via Apache Wicket] ml-node+2967914-1064517663-152...@n4.nabble.comml-node%2b2967914-1064517663-152...@n4.nabble.com wrote: in that case either your System or your System.out is null :) -igor On Thu, Oct 7, 2010 at 11:35 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=2967914i=0 wrote: 186 is System.out.println(_numbers); -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967903.htmlhttp://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967903.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967914i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967914i=2 - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967914i=3 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967914i=4 -- View message @ http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967914.html To unsubscribe from RadioChoice - what's wrong?, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2967576code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTY3NTc2fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967920.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: RadioChoice - what's wrong?
Sure, but I posted pretty much everything related to radiochoice :) So I am just not doing some obvious important steps for making RadioChoice work :) Code, with all non-related parts removed, looks like that: public class Registration extends WebPage { public Registration() { add(new FeedbackPanel(errorMsg)); //New user registration form FormString regForm = new FormString(registrationForm, new ModelString()) { static final ListString NUMBERS = Arrays.asList(new String[] { 1, 2, 3 }); private RadioChoiceString rc; { RadioChoiceString rc = new RadioChoiceString(numberRadioChoice, new ModelString(), NUMBERS).setSuffix(); add(rc.setRequired(true)); } @Override public void onSubmit() { String _numbers = rc.getModelObject(); System.out.println(_numbers); } }; add(regForm); } } On Fri, Oct 8, 2010 at 3:58 PM, Zilvinas Vilutis [via Apache Wicket] ml-node+2968370-862341428-152...@n4.nabble.comml-node%2b2968370-862341428-152...@n4.nabble.com wrote: Oh come on! no one will want to steal your non-working code! Use http://pastebin.com/ to show your code if you want someone's help ;) Žilvinas Vilutis Mobile: (+370) 652 38353 E-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=0 On Thu, Oct 7, 2010 at 11:35 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=1 wrote: 186 is System.out.println(_numbers); -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967903.htmlhttp://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967903.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=2 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=3 - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=4 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2968370i=5 nothing is impossible -- View message @ http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2968370.html To unsubscribe from RadioChoice - what's wrong?, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2967576code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTY3NTc2fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2968833.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
RadioChoice - what's wrong?
Hi, I am trying to get through with the very basics of Wicket - radiochoice. But somehow I got stuck and all solutions I tried made my problems even worse... So, what am I doing wrong? I have this code: static final ListString NUMBERS = Arrays.asList(new String[] { 1, 2, 3 }); private RadioChoiceString rc; { RadioChoiceString rc = new RadioChoiceString(numberRadioChoice, new ModelString(), NUMBERS).setSuffix(); add(rc.setRequired(true)); } String _numbers = rc.getModelObject(); System.out.println(_numbers); When I submit the form I get: NullPointerException What am I doing wrong then? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967576.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: RadioChoice - what's wrong?
I doubt anything else is needed, it throws NullPointerException at syso attempt. Rest of the form is working properly - I can of course post more code, but what would be needed? Stacktrace is pretty generic too... org.apache.wicket.RequestCycle logRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = registrationForm]] threw an exception org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = registrationForm]] threw an exception ... ... ... Caused by: java.lang.reflect.InvocationTargetException at com.google.appengine.runtime.Request.process-a82d7b755ed3a9dd(Request.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:43) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) ... 50 more Caused by: java.lang.NullPointerException at com.spiritia.auth.Registration$1.onSubmit(Registration.java:186) at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1538) at org.apache.wicket.markup.html.form.Form.process(Form.java:934) at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:896) ... 55 more On Thu, Oct 7, 2010 at 11:51 PM, Igor Vaynberg-2 [via Apache Wicket] ml-node+2967607-1764587878-152...@n4.nabble.comml-node%2b2967607-1764587878-152...@n4.nabble.com wrote: cant help you without seeing more code and stack -igor On Thu, Oct 7, 2010 at 2:28 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=2967607i=0 wrote: Hi, I am trying to get through with the very basics of Wicket - radiochoice. But somehow I got stuck and all solutions I tried made my problems even worse... So, what am I doing wrong? I have this code: static final ListString NUMBERS = Arrays.asList(new String[] { 1, 2, 3 }); private RadioChoiceString rc; { RadioChoiceString rc = new RadioChoiceString(numberRadioChoice, new ModelString(), NUMBERS).setSuffix(); add(rc.setRequired(true)); } String _numbers = rc.getModelObject(); System.out.println(_numbers); When I submit the form I get: NullPointerException What am I doing wrong then? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967576.htmlhttp://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967576.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967607i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967607i=2 - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967607i=3 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2967607i=4 -- View message @ http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967607.html To unsubscribe from RadioChoice - what's wrong?, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2967576code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTY3NTc2fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioChoice-what-s-wrong-tp2967576p2967624.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
Best practice for DropDownChoice?
Hi, I was looking at many threads here about that matter and even more google links, after not really being able to properly use examples from Wicket in Action and few others. So I wonder - what's the best and most common way to implement DropDownChoice and map the value at the same time [well, option that'd easily work with radio buttons too]. I have seen many suggestions that were creating even few classes, then extended them, added other stuff. There must be easier solution, right? :) All I want is some displayed value [easy to localis too of course] + mapping it to int value [I am fine with creating new variable and then changing real one, instead of trying to map it to some class at once]. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Best-practice-for-DropDownChoice-tp2937257p2937257.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
checkGroup - 2 out of 5?
Hi, I want to limit users to check exactly 2 options out of X. How can I do that? I'd also like it to switch last chosen one to new one, if user has already picked 2 [so it'd deselect last one and choose another, instead of not doing anything at all]. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/checkGroup-2-out-of-5-tp2527723p2527723.html Sent from the Wicket - User 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: checkGroup - 2 out of 5?
Oh, I hoped that it can be avoided. So anyone has AJAX example at hand? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/checkGroup-2-out-of-5-tp2527723p2527763.html Sent from the Wicket - User 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