WiQuery DatePicker and Ajax Request
Hi, guys. Here is a problem I met today: When I use DatePicker and I change it's model when ajax request received, on client side date picker's button image doubles. It happens because on every request date picker is initialized again and renders new image every time, but old one doesn't disappear, so user can see several button images. Here is simple code snippet for testing: FormVoid form = new FormVoid( form ); add( form ); DatePickerDate datePicker = new DatePickerDate( datepicker, new ModelDate(), Date.class ); datePicker.setButtonImageOnly( true ); datePicker.setShowOn( ShowOnEnum.BUTTON ); datePicker.setOutputMarkupPlaceholderTag( true ); form.add( datePicker ); FormComponentString submitBtn = new AjaxButton( submit, new ModelString( Submit ), form ) { @Override protected void onSubmit( AjaxRequestTarget target, Form? form ) { Component datePicker = getForm().get( datepicker ); datePicker.setDefaultModelObject( null ); target.addComponent( datePicker ); } }; form.add( submitBtn ); Here is markup: form wicket:id=form input type=text wicket:id=datepicker/ input type=button wicket:id=submit/ /form Is there any solution? Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: WiQuery DatePicker and Ajax Request
Thanks for this fast reply! Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
CheckBox and Repeater
Hi, guys. I've got repeater, each row of which is backed by model object. Each row has check box, so I can select multiple rows and delete appropriated model objects when 'delete' button pressed. I have in mind two ways how to implement this. One is to parse raw response and retrieve post parameters that indicates which rows were selected. Another one is to have a list of check boxes outside of repeater and fill this list with any call to populateItem() method. When form is submitted, walk throw this list to find which rows were selected, then get appropriated models from parent ListItem and remove them. Could you give my advice? Maybe you have another approach to implement this? Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Set Current DropDownChoice Item (Selected)
Hello. Use setModel() in this case. Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: wicket question
Hi. What's wrong with wicket's form? Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SV: PageableListView to work with Set
Hi. See Java Doc for PageableListView http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/list/PageableListView.html and it's ascendant http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/list/ListView.html. From Java Doc: A ListView is a repeater that makes it easy to display/work with Lists. However, there are situations where it is necessary to work with other collection types, for repeaters that might work better with non-list or database-driven collections see the org.apache.wicket.markup.repeater package. Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SetObject with PageableListView
Why are you trying to use component that is intended to work with java.util.List when your domain object is Set? Try one of AbstractPageableView implementations, f.e. DataView. Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DatePicker to pick a year
Hi. Why don't you use wiQuery? BTW, it's not a good idea to set markup id, because you're not sure whether it's unique across entire page. Let it be set by framework. If you don't want to use wiQuery, use header contribution to inject jquery related code from java code to page. In this case you can use getMarkupId() to retrieve actual input's id and put it to jquery related code. Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: onSubmit not getting invoked using AjaxButton
Hey, in development mode you can check ajax debug panel. So, you can see all ajax request. If it doesn't help could you, please, provide sample source? Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: PropertyModel expression for collection object
Hello. See this link for property expression language: https://cwiki.apache.org/WICKET/property-expression-language.html property.index: If the property is a List or Array then the second property can be used as a index on that list/array like this: 'mylist.0'. Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Switching between wicket tabs
Hello. What's problem with button? Why do you need tabbed panel's markup id? If button that changes selected tab is in another panel, you could pass callback to panel's constructor Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Switching between wicket tabs
Hello. Could you please give some details? Or sample? Best regards, Alexander. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxTabbedPanel and location line
So, any suggestion here? Best regards, Alexander.
AjaxTabbedPanel and location line
Hi, guys. I've got one page that contains AjaxTabbedPanel component. Each ITab contains AjaxTabbedPanel. So, page contains tabs and subtabs. When different tabs selected, location path isn't changed. Could you suggest me how to change location for every selected tab? For example, there are 'tab1' and 'tab2'. 'tab1' contains 'subtab1' and 'subtab2', The same for 'tab2'. I'd like it to work as following: when user selects tab1/subtab1 location line would contain http://domain.com/tab1/subtab2, when user selects tab2/subtab1 location line would contain http://domain.com/tab2/subtab1, etc. Also, it would be great if user types http://domain.com/tab2/subtab1 in location line and appropriated tab would be opened. Any idea how to make this? Best regards, Alexander.
AjaxFormComponentUpdatingBehavior and AttributeAppender
Hi, guys. I noticed AjaxFormComponentUpdatingBehavior overwrites earlier added with AttributeAppender/AttributeModifier handlers. Could you give me any suggestion how to make them coexistent? Best regards, Alexander.
set focus on IE
Hi, guys. Here is code I'm using to show modal window in response of AjaxLink onClick event: public void onClick( AjaxRequestTarget target ) { modal.show( target ); target.focusComponent( getComponentToBeFocuse() ); } It's working correctly on FireFox and Opera, but isn't working on IEv7/IEv6. Could you give me any suggestion? Best regards, Alexander.
Google Guice and Wicket
Hi, guys. I'm trying to use wicket-guice extension in my wicket application. My application instantiates some services in my session implementation and passes some parameters to it when user is authenticated. I'm trying to inject these services using Guice. But they're not injected in my session implementation, because guice extension makes injection only to wicket components. In this case, I'm trying to do this explicitly via my base page: Injector injector = getApplication().getMetaData( GuiceInjectorHolder.INJECTOR_KEY ).getInjector(); injector.injectMembers( getSession() ); This time, I catch this: 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. If I set injected services that are injected to base page directly to session like that: MySession session = (MySession) getSession(); session.setMyService( myService ); When I catch the same OutOfScopeException when I'm trying to invoke any method of this service from my session implementation. Could you give me any advise? How could I use injected services in session implementation? Best regards, Alexander.
Re: Google Guice and Wicket
Great! Thanks! Best regards, Alexander.
Re: TabbelPanel doesnt work in appengine
Hey. I met the same problem when I started to implement my app using Wicket and GAE. On GAE there is problem with serialization. GAE prohibits to use replacement substitution, so WIcket's methods like Component#modelChanged() or Component#modelChanging() cause AccessControlContext. To fix this problem I extended TabbedPanel class and overwrote some significant methods. Here is code for you. It works on GAE for my application more then 3 month without any problem. /** * @author dominity * * Implementation of Wicket's {...@link TabbedPanel} that has ability to work on * Google App Engine. Currently there is problem with serialization of model. * GAE prohibits to use replacement substitution, so any time tab switching is * invoked, AccessControlContext is threw. To avoid this behavior * {...@link Component#setDefaultModelObject(Object)} is overwritten to * hide {...@link Component#modelChanging()} and * {...@link Component#modelChanged()} methods invocation before/after model's * object setting. Also, {...@link TabbedPanel#setSelectedTab(int)} is overwritten * to switch from using of {...@link Component#setDefaultModelObject(Object)} to * {...@link #setDefModelObject(Object)}. */ public class GAETabbedPanel extends TabbedPanel { // copy of boolean array from TabbedPanel to avoid serialization problems on // GAE private transient Boolean[] tabsVisibilityCache; /** * @param id * id of span on markup page * @param tabs * list of {...@link ITab}s * @see TabbedPanel */ public GAETabbedPanel( String id, ListITab tabs ) { super( id, tabs ); } @Override public void setSelectedTab( int index ) { if ( index 0 || ( index = getTabs().size() index 0 ) ) { throw new IndexOutOfBoundsException(); } // here is only change in comparison to TabbedPanel#setSelectedTab(int) setDefModelObject( new Integer( index ) ); final Component component; if ( getTabs().size() == 0 || !isTabVisible( index ) ) { // no tabs or the currently selected tab is not visible component = new WebMarkupContainer( TAB_PANEL_ID ); } else { // show panel from selected tab ITab tab = getTabs().get( index ); component = tab.getPanel( TAB_PANEL_ID ); if ( component == null ) { throw new WicketRuntimeException( ITab.getPanel() returned null. TabbedPanel [ + getPath() + ] ITab index [ + index + ] ); } } if ( !component.getId().equals( TAB_PANEL_ID ) ) { throw new WicketRuntimeException( ITab.getPanel() returned a panel with invalid id [ + component.getId() + ]. You must always return a panel with id equal + to the provided panelId parameter. TabbedPanel [ + getPath() + ] ITab index [ + index + ] ); } addOrReplace( component ); } /* duplication of the same method at TabbedPanel class in case of * setDefaultModelObject(Object) overwriting.*/ private boolean isTabVisible( int tabIndex ) { if ( tabsVisibilityCache == null ) { tabsVisibilityCache = new Boolean[ getTabs().size() ]; } if ( tabsVisibilityCache.length 0 ) { Boolean visible = tabsVisibilityCache[ tabIndex ]; if ( visible == null ) { visible = getTabs().get( tabIndex ).isVisible(); tabsVisibilityCache[ tabIndex ] = visible; } return visible; } else { return false; } } /** * It's duplication of {...@link #setDefaultModelObject(Object)} except it * doesn't invoke {...@link #modelChanging()} and {...@link #modelChanged()} * before/after model's object setting. This prevents * {...@link AccessControlException} is threw during tab switching. * * @param object *The object to set * @return this * @see #setDefaultModelObject(Object) */ @SuppressWarnings( unchecked ) public final Component setDefModelObject( final Object object ) { final IModelObject model = (IModelObject) getDefaultModel(); // Check whether anything can be set at all if ( model == null ) { throw new IllegalStateException( Attempt to set model object on null model of component: + getPageRelativePath() ); } // Check authorization if ( !isActionAuthorized( ENABLE ) ) { throw new UnauthorizedActionException( this, ENABLE ); } // Check whether this will result in an actual change if ( !getModelComparator().compare( this, object ) ) {
Google Charts integration
Hi, guys. Is there currently any integration of google charts with wicket? I've found some articles like that http://www.codecommit.com/blog/java/a-wicket-api-for-google-charts. But they are really old. So, I'm curious whether there is any active integration with google charts. Best regards, Alexander.
Re: Google Charts integration
Thanks for replies, guys. Yes, I've checked this project. As I understand it hasn't been updates a lot of time. I guess it has lived without update from 2007. I can see that it's supporting not so many types of chart as Google Charts is providing currently. And Major Peter is right, it depends only on WebCompont of wicket. So, I guess it won't have problem with new wicket releases. Best regards, Alexander.
ModalWindow and Multipart request
Hi, guys. I'm developing a form that allows user to upload file and then shows message in modal window. Modal window appears the same time user pushes upload button and shows busy indicator. When file is uploaded, modal window shows status message. This approach works fine for single requests (not multipart). But with multipart requests modal window behaves in strange way. In doesn't show any content. For busy indicator I'm using AjaxLazyLoadPanel. It has getLazyLoadComponent() method that is invoked when modal window is shown. But, when multipart request is passed, this method isn't invoked. Could you give my any ideas where is problem? Best regards, Alexander.
Re: Page Expired
Hi, I don't think that this is problem. 'Page expired' message appears immediately when I click link. There is no timeout or something like that. I serf pages, then click link and 'Page Expired' message appears. As you can see there is log's message that says there is no version manager for this page. COuld it be problem? Best regards, Alexander.
Page Expired
Hi, guys. I've got problem with 'Page Expired' message. I'm developing application that is worked on GAE. It has one page with help content. There is two help pages. Help page contains two separated divs. One div for table of content, second - for content. When user clicks on link, page is reloaded with appropriated content. So, when I load this page first time all works fine. But when I click on any link, I get 'Page Expired' message. I set log level to debug. Here is some messages: 13:46:14,140 DEBUG [org.apache.wicket.Session] - Getting page [path = 3:tabpanel:panel:toc-panel:help.panel.navigation:1:help.panel.link, versionNumber = 1 13:46:14,141 INFO [org.apache.wicket.Page] - No version manager available to retrieve requested versionNumber 1 13:46:14,141 INFO [org.apache.wicket.AccessStackPageMap] - Unable to get version 1 of page [Page class = com.dominity.web2care.wicket.pages.BasePage, id = 3, version = 0] 13:46:14,142 DEBUG [org.apache.wicket.RequestCycle] - setting request target to [bookmarkablepagerequesttar...@974813593pageclass=org.apache.wicket.markup.html.pages.pageexpirederrorpage] So, could you explain me what's wrong with this and what is it about: No version manager available? If you'd like I show you source code and markup. BTW, please, bear in mind, that the same page works fine of GAE SDK without any page expirations, but on server side I get always Page Expired message. Best regards, Alexander.
Re: Page Expired
Hi. I'm using org.apache.wicket.protocol.http.HttpSessionStore. Guess it's not cause, because other links from other pages work well. Best regards, Alexander.
Modal Window, cookie and component update
Hi, guys. I'm trying to create sing in page in modal window. So, there is home page with sign in link. When user clicks the link modal window appears with login/password form. When user submits valid authentication credentials modal window is closed and sign in link is changed to sign out link. Here is some code snipets: Home page: public class HomePage extends WebPage { . public HomePage() { this.signInLink = new AjaxLinkVoid( SIGN_IN_LINK_ID ) { @Override public void onClick( AjaxRequestTarget target ) { modal.show( target ); } }; this.signOutLink = new LinkVoid( SIGN_OUT_LINK_ID ) { @Override public void onClick() { getSession().invalidate(); setResponsePage( BasePage.this ); } }; signInLink.setOutputMarkupId( true ); signOutLink.setOutputMarkupId( true ); if ( ((CustomSession) getSession()).isSignedIn() ) { signInLink.setVisible( false ); } else { signOutLink.setVisible( false ); } add( signInLink ); add( signOutLink ); /* here goes modal window initialization*/ } public void setSignedIn( final boolean isSignedIn, final AjaxRequestTarget target ) { signInLink.setVisible( !isSignedIn ); signOutLink.setVisible( isSignedIn ); target.addComponent( signInLink ); target.addComponent( signOutLink ); } } In modal window there are two inputs for login and password and ajax button. When user pushes submit button. setSignedIn() method of HomePage is called and modal window is closed. First problem is sign in link disappear when modal window is closed, but sing out link doesn't appear (when I check ajax response, I can see that component for sing out link was sent). Second problem is firefox doesn't save value of login/password as it does usually(I guess it's issue of modal window. Also, if setPersisted() method is invoked for login field, there is an item in cookie, but it doesn't appear in login field next time user goes to login page.). Third problem is if error() method is called, error message doesn't appear in page, even though feedback panel is added( I was trying to add feedback panel to home page or to panel that is added to modal window without success. In any case in console WARN message appeared.) Could you give me any suggestions? Best regards, Alexander.
Re: Modal Window, cookie and component update
Hey. Thanks a lot for help. Feedback panel is shown now and sign out link appears when it should. But firefox still doesn't want to save and insert values for username/password fields. Usually, firefox asks to save login/password when form is submitted, but when form is submitted from modal window with ajax button, firefox doesn't ask anything. Also, usually firefox provides some variants of text that fits this type of input field. But this time for username input field it provides any information or some other information, but not that was typed earlier. Also, I've got another question. How could I make modal window to fit to his content. I'm using setUseInitialHeight( false ), so height of modal window fits height of content, but width is still to large. Best regards, Alexander.
PropertyListView problem
Hi, friends. Could you help me with subject? Here is the situation. I want to create manageable list of item, so I could add new items to it, update current state of each item and remove items. I'm using ListView for this purpose. Here is sample code that works with ListString that describes items: public class ItemsPanel extends Panel { // here goes fields definition section // list of items to show private ListString items; public ItemsPanel( String id ) { super( id ); items = new ArrayListString(); items.add( String 0 ); items.add( String 1 ); final ListViewString itemsList = new PropertyListViewString( items, new PropertyModelListString( this, items ) ) { @Override protected void populateItem( final ListItemString item ) { final WebMarkupContainer baseDiv = new WebMarkupContainer( title ); baseDiv.add( new Label( text, item.getModel() ) ); final WebMarkupContainer deleteImg = new WebMarkupContainer( delete.arrow ); deleteImg.add( new AjaxEventBehavior( onClick ) { @Override protected void onEvent( AjaxRequestTarget target ) { testStrings.remove( item.getModelObject() ); target.addComponent( ItemsPanel.this ); } }); baseDiv.add( deleteImg ); item.add( baseDiv ); } }; itemsList.setReuseItems( true ); itemsList.setOutputMarkupId( true ); add( itemsList ); add( new AjaxLinkVoid( add ) { @Override public void onClick( AjaxRequestTarget target ) { testStrings.add( New String + (items.size() + 1) ); target.addComponent( ItemsPanel.this ); } }); setOutputMarkupId( true ); } } Markup for this class is: html body wicket:panel a wicket:id=addAdd item/a div wicket:id=items div wicket:id=title class=list_title span class=label wicket:id=text[Here goes a text]/span img src=/img/delete.gif class=delete_arrow wicket:id=delete.arrow/ br/ /div /div /wicket:panel /body /html It'is working perfectly, but when I'm changing ListString to ListCustomType, where CustomType is custom class with appropriated info, when I push delete arrow last item from showed list is removed, not that one that I want to delete. But correct item is removed from backed list of items. I can't understand what's wrong. During debug I can see that backed list of items contains right set of items, but in html appeared other list of items. Best regards, Alexander.
Re: PropertyListView problem
Thanx a lot! Now it's working fine. Didn't think problem is in setReuseItems. Thanx again. Best regards, Alexander.
Re: dynamically adding components to a ListView
Hi, guys. Just use PropertyModel. Instead of this: code container.add(new ListViewMyPanel(panels, panels) { ... } /code use this code container.add( new ListViewMyPanel(panels, new PropertyModelList? extends MyPanel( this, panels ) ) { ... } /code where 'this' is referenced to instance of class that contains list of panels as it's property. And check PropertyModel description at Doc API. Best regards, Alexander.
Re: Component hierarchy question
Hi. I'm not sure. But when you call add() method you pass reference to the certain component. If you create new object and assign reference to it, you just create reference to new object, but old one references to old object. For example, // here is new component creation 1. Component c = new Component( ); 2. add( c );// add to component tree 3. c = new Component( .. );//initialize another component 4. replaceWith( c );// replace old component with new one if are you asking why sould 4th lines be invoked, the question is simple, you have to push reference to new component to component tree. If you are why doesn't it work with out 4th, try to read about references in Java. Best regards, Alexander.
Custom DropDownChoice with css style
Hi, guys. I'm trying to implement DropDownChoice that could render select tag with possiblity to add style with css. What do I mean: select tag rendering is OS dependent. So, plain select element is always ugly. There is no possibility to change arrow, or border of drop down list only with css. One of the ways to resolve this problem is to add span tag before select tag to show currently selected value, then apply to it desired background and any desired styles and give select tag's opacity zero value. So, drop down menu would appear any time user clicks on span element. To push selected value to span onChange method for select tag is appropriated. So, I've created this class: code public class StyledDropDownChoiceT extends DropDownChoiceT { /*Here goes constructors and StyleDropDownSpan is added as behavior. */ @Override protected void onComponentTag( ComponentTag tag ) { tag.put( onChange, var span = document.getElementById(' + getMarkupId() + -span'); var select = document.getElementById(' + getMarkupId() + '); span.innerHTML = select.options[ select.selectedIndex ].innerHTML; ); //todo move javascript output to renderJavascript( CharSequence, String ) super.onComponentTag( tag ); } private class StyledDropDownSpan extends AbstractBehavior { @Override public void onComponentTag( Component component, ComponentTag tag ) { replaceComponentTagBody( getMarkupStream(), tag, span class=\combobox\ id=\ + component.getMarkupId() + -span\ + component.getDefaultModelObjectAsString() + /span ); super.onComponentTag( component, tag ); } } } /code So, this code works fine with usual drop down choices. But, when I'm trying to update list of choice via AJAX call, another span element appear on the page. So, I get that span tag is added any time dropdownchoice is rendered. Could you help me to resolve this issue? Best regards, Alexander.