Refresh Child panel with AjaxRequestTarget - wicket

I am new to wicket and stuck in a Panel refresh problem with AjaxRequestTarget. I am clarifying my scenario below.
In the Ui I have a Panel (A) which contains another Panel (B) and B contains some buttons and table. I Panel A, I have a Event which will refresh My Panel B with AjaxRequestTarget. On event I am adding Panel B in my AjaxRequestTarget.add() but it's not calling my initialize method in Panel B. So, Panel B is not refreshing properly.
It's a existing code so, can't move the event to Panel B. So, need to do something from Panel A itself.
Clarifying more:
After few debgus I found my problem in some other places. It's not about refreshing Panel B. It's all about refreshment of Panel A.
Panel A extends Panel and when I am refreshing with Ajax Timer Panel A's components scrumble up and due to this My Panel B also scrumbled up. So, Can anyone help me on that

I think you need to put your "refreshing" code of the Panel B in the onConfigure method which is called once per request.
If you provide code sample my answer could be improved with an example.

onInitialize is called when your component is added to the component hierarchy. onConfigure is called once per request processing for each component that is part of the request cycle (which yours is during Ajax if you add it to the Ajax request target). It is called for invisible components as well. Don't forget to call super().

Related

Web-site with two Composite per page. Due to bad design?

I'm creating a web-site using GWT for the first time. The aplication has two Composite class, one of them is a menu and the other one is where I show de info about the specific menu that has been clicked. I'm using MVP, the class History and the interface ChangeValueHandler to switch among different pages.
I have one pair presenter-view for each Composite. The app begins well creating the menu and the section info. When you click in the menu it works fine showing the information and the token browser is changed. The thing is that if you load a page(eg: myapp.com#register) without loading the home page, it doesn't show you the menu. It loads the Composite section info, but not the Composite menu (the Composite menu is load with myapp.com#home).
I think it's because of a bad design of the application, but I don't know how to do that in other way. If the app only had one Composite it wouldn't be a problem, but when there are 2 or more Composite per page I don't know how to manage the whole thing to work properly.
It's difficult to tell what exactly is wrong, because of the lack of code. So I'm guessing. You should design to act on the PlaceChangeEvent instead of the ValueChangeEvent. That means a menu click should fire the place change and then the application will handle this event. That way you unbind the menu actions from your content pages. And think more of each page as a separate entity. Also take a look at the GWT Activity mechanism and how it helps having a main page that is always the same and on that main page a content area that changes depending on the page actually shown.
You should include your menu in each page instead of creating it once in the home page and then keeping it on screen. I assume you create the menu and add it to the DOM via
RootPanel.get().add(myMenuWidget);
If you are using UIBinder it should be pretty straightforward to include the menu in each page, just a matter of adding the corresponding tag in each .ui.xml file of your pages.

forms showing in runtime as soon as they are created

In runtime when the forms are being created, 2 forms constantly keep appearing when I haven't programmed them to show as soon as they are created, and my system runs. I was wondering why this happened and whether there is anything to solve this? I don't think I need to show my code here since it's pretty basic and there is none for the OnCreate event.
From the main menu, use Project->Options->Forms, and remove the forms you don't want to see from the Auto-create list. (Click the >> button to move them from the left side to the right side.)
(It's worth mentioning that you can also affect the order in which any autocreated forms or datamodules are created from that dialog by just dragging them up or down in the list. Note that the first form to be created becomes the application main form, so when it is closed the application will close as well; this means that the only thing above your main form in the autocreate list should be datamodule(s) that are accessed by the main form.)
If you never want any forms auto-created, go to Tools->Options->Environment Options->Form Designer, and uncheck the very last item labeled Auto create forms & data modules at the bottom. Note that your main form will always be auto-created, as it's what controls the application's lifetime for form based applications.
By default delphi creates all the forms in the beginning. You can open the .dpr file and delete the ones that you don't need. You could also do that from the UI.
For the forms that you don't want to appear at the start of runtime, go to the properties of the form (lower left hand side) and uncheck Visible. This should do the trick

Windows Forms Error Provider does not display in custom tab control

I'm trying to build a Wizard framework in Windows Forms. I've managed to glean a lot of useful tips from this and other sites which have gotten me very close to success. However, I'm having a problem with displaying an ErrorProvider on any tab page other than the first page of the wizard.
My Wizard control is a UserControl. It contains a custom tab control that I've derived from TabControl so that I can hide tabs and ignore attempts to navigate between tabs using keypresses, along with the usual collection of Back/Next/Finish/Cancel buttons at the bottom of the control.
I've used reflection to allow me to raise the validation events on a particular TabPage that belongs to the Wizard Control when I hit the Next button. (I don't want to validate the whole TabControl, only the currently active page.) When I do this, I see in the debugger that my Validating routine for the controls on the current tab page is correctly called and I see that I've called the ErrorProvider that I've attached to the particular control (a TextBox in this case) with a valid error message. I set Cancel to true for the CancelEventArgs in the validating routine and that's picked up by the code that uses the reflection mechanism so that I see that I've failed and don't change tabs. And I set the focus successfully to the control that failed validation.
So all that appears to be working just fine.
Unfortunately, I don't see the ErrorProvider's cheery blinking icon unless I'm on the first tab page. For all of the other tab pages, there's no message visible at all.
I'm baffled. Any thoughts? I can provide code snippets, if helpful.
Thanks!
I assume that in your case the button that moves to the next step of the wizard is placed outside (below) the TabControl
I noticed that the icon is displayed correctly if I pressed the button without releasing the mouse button. It seems that the button outside the container gets focused event though a validation error has occurred (normally you would not be able to leave the active control).
I worked around this issue by registering an event handler for the buttons MouseUp event to "refocus" the TabControl:
private void cmdOK_MouseUp(object sender, MouseEventArgs e)
{
tabControl1.Focus();
}
Note: you also need to set your forms ActiveControl property the one of the controls that failed validation.

Editing Records with MVVM/MVVM-Light

I have created a very simple wpf app with mvvm light.
I have rows in a list view, these are templated representations of Book objects.
I can click a row, then click an edit button, this button loads a new window and sends the new window the book to edit (using mvvm-light's Messenger).
The issue I have is when I edit the record in my new window the data on the main form is updated. The text boxes are bound to the object received via the Messenger.
I know this is because I have essentially passed a reference to the same Book object around the place, therefore I update in one place.. and voilĂ  it updates on the main page too.
What I would like to know is.. is there a standard way/method/concept to achieve what I am trying to do? i.e. create an "edit" page/screen with the option of discarding the edits?
thanks.
Could you make your entity implement ICloneable and create a clone for editing?

Calling a Composite's GWT method from another Composite

I'm new to GWT and trying to make a simple app (like a small version of fmylife). Up to now i made a composite that loads the facts and another composite that has a form to submit new facts (this one has a load method that clear the list and populate again).
I have a button that when you press it, it shows a Window with a form.
That form is used to add new Facts. But I want to refresh the main page when the Fact is added correctly and close this window.
How should I do this? Should I pass some kind of callback to the Window form?
Edit: I didn't express well enough, Window is a DialogBox provided by smartGWT.
Take a look at Events and the Event Bus.
You can also watch this video for a better explanation.
Sure, why not? Pass a callback with some method like onSave to the composite contained in the DialogBox. Design the flow in such a way that the DialogBox composite is always editing the fact model, and it it not be aware of whether it is creating a new fact model or editing an existing one. Let the DialogBox invoke onSave using the callback, when the user submits the popup.
Keep the fact collection data structure CRUD logic out of the DialogBox composite.
You should use DialogBox or PopupPanel instead of opening a new window (most modern browsers opt to open a new tab either way). That way you won't leave the page (that's the whole point of this AJAX thing, right?), you'll just overlay a new Widget over it and then on "submit" it will hide/destroy itself and add a new fact (without reloading the whole page).
Agreed with the DialogBox and PopupPanel solution above. However, if you'd still like to use Window, the following solution comes to mind.
Extend Window and provide hooks to the values you want back. Then, when you create the new CustomWindow, call the addWindowCloseHandler method to get notified when the CusomWindow is being closed. On that event, get the values you need and allow the window to close. Then make an async call to refresh your main page.