Re: WiQuery: positioning a dialog when reusing it

2014-08-20 Thread Martin Dietze
I have looked into that issue a bit further.

On 17 August 2014 17:23, Mihir Chhaya mihir.chh...@gmail.com wrote:
 I have used WQuery Dialog for Wicket 1.4 and could make it work in center
 using setMinimumHeight and setMinimumWidth methods when adding dialog.

That's true, but this is part of the problem. Since this only takes
effect when adding the dialog, it will not change after the page  (and
therefore the generated Javascript code containing the settings) has
been rendered.

Since the dialog is shown using Javascript, Wicket will normally not
even know about this. One can probably add some Javascript code to the
links that open the dialog, but that does not seem very robust as
there does not seem to be any official API for manipulations like this
(one would have to read the generated Javascript code and write some
stuff that changes the settings).

I now ended up with two global dialogs, one for a small dialog that
is shown in the center of the page and one for large dialogs that is
positioned at the top. Not elegant, but it does the job.

I actually doubt that using WiQuery for the dialogs actually leads to
any benefit at all. I inherited the code I am working with, and not
using Wicket's standard dialog API seems to make code harder to
understand, less maintainable why not leading to obvious optimization.

Cheers,

Martin

-- 
-- mdie...@gmail.com --/-- mar...@the-little-red-haired-girl.org 
- / http://herbert.the-little-red-haired-girl.org / -

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: WiQuery: positioning a dialog when reusing it

2014-08-20 Thread Mihir Chhaya
In fact I have found WiQuery dialog more helpful. I am sharing my code with
you; just to show my version of using the dialog. Not necessarily the best
way, but is working for me and very helpful.

(I HAVE DEVELOPED MY VERSION USING ERNESTO REINALDO'S ORIGINAL SUGGESTION
FOR DIALOG BOX CREATION, AND WITH ADDITIONAL INTERFACE STRUCTURE FOR MY OWN
PURPOSE.).

Please note that the Dialog creation class is part of interface which also
has methods used within extended classes; to be implemented in the
respective page classes when adding the dialog.

package mypackage;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.odlabs.wiquery.ui.dialog.AjaxDialogButton;
import org.odlabs.wiquery.ui.dialog.Dialog;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Chhaya-MX on 6/23/14.
 */
public interface MyDialogBox extends Serializable {

public static final long serialVersionUID = 1L;

public enum Btn{
YES,
NO,
RESET,
DEFAULT
}

public class MyDialogBoxWindow extends Dialog {

/**
 *
 */
private static final long serialVersionUID = 1L;

public AjaxDialogButton YES;
public AjaxDialogButton NO;
public AjaxDialogButton RESET;

MapBtn, String btnTitles = new HashMapBtn, String();

//Note the window positioning as parameter to the constructor
public MyDialogBoxWindow(String propertyName, String title,
WindowPosition windowPosition) {
super(propertyName);
setTitle(title);
setMinHeight(200); //You can customize as input parameter or
have protected method to set (similar to setTitle above)
setMinWidth(800); //You can customize as input parameter or
have protected method to set (similar to setTitle above)
setModal(true);
setAutoOpen(false);
setPosition(windowPosition);

setButtonTitles();

YES = dialogYesButton(btnTitles.get(Btn.YES));
NO = dialogNoButton(btnTitles.get(Btn.NO));
RESET = dialogResetButton(btnTitles.get(Btn.RESET));
setButtons(YES, NO);
setOutputMarkupId(true);
}

public void setButtons(AjaxDialogButton... buttons) {
super.setButtons(buttons);
}

private AjaxDialogButton dialogYesButton(String title) {
if (null == title || title.trim().length() = 0){
title = Yes;
}
return new AjaxDialogButton(title) {

private static final long serialVersionUID = 1L;

@Override
protected void onButtonClicked(AjaxRequestTarget target) {
onConfirmation(target);
}
};
}

private AjaxDialogButton dialogNoButton(String title) {

if (null == title || title.trim().length() = 0){
title = No;
}

return new AjaxDialogButton(title) {

private static final long serialVersionUID = 1L;

@Override
protected void onButtonClicked(AjaxRequestTarget target) {
onCancel(target);
close(target);
}
};
}

private AjaxDialogButton dialogResetButton(String title) {

if (null == title || title.trim().length() = 0){
title = Reset;
}

return new AjaxDialogButton(title) {

private static final long serialVersionUID = 1L;

@Override
protected void onButtonClicked(AjaxRequestTarget target) {
//Implement ME...
}
};
}

public void onConfirmation(AjaxRequestTarget target) {
//Override ME
}


public void onCancel(AjaxRequestTarget target) {
//Override ME
}

protected void setButtonTitles(){
}

public void setBtnTitles(MapBtn, String btnTitles) {
this.btnTitles = btnTitles;
}
}
}


Now in your wicket page/panel get MyDialogBox method. Check how you can
pass different WindowPosition constant to meet your requirements:

   private void addConfirmationDialog(final DataGridGridListHTOffender,
GridObject grid) {
confirmationDialog = new
MyDialogBox.MyDialogBoxWindow(confirmationDialog, Are you sure you want
to delete offender(s)?, Dialog.WindowPosition.TOP) {

/**
 *
 */
private static final long serialVersionUID = 1L;

/* (non-Javadoc)
 * @see
mypackage.MyDialogBox.MyDialogBoxWindow#setButtonTitles()
 */
@Override
protected void setButtonTitles() {
MapMyDialogBox.Btn, String btnTitles = new
HashMapMyDialogBox.Btn, String();
btnTitles.put(MyDialogBox.Btn.YES, Confirm);
btnTitles.put(MyDialogBox.Btn.NO, No);

 

Re: WiQuery: positioning a dialog when reusing it

2014-08-17 Thread Mihir Chhaya
Martin,

I have used WQuery Dialog for Wicket 1.4 and could make it work in center
using setMinimumHeight and setMinimumWidth methods when adding dialog. Have
you tried those? You could pass different values for height and width from
the source when creating to match your requirements.

For position, I have not tried though.

-Mihir.


On Fri, Aug 15, 2014 at 8:01 AM, Martin Dietze mdie...@gmail.com wrote:

 In my application I am using WiQuery's 'Dialog' for a global page
 dialog that gets constructed in my page base class. Each time I want
 to show a dialog I embed a different panel in it and then show it.

 Usually I would like to display smaller dialogs that fit on the screen
 using WindowPosition.CENTER while for larger (i.e. longer) dialogs
 WindowPosition.TOP would be more appropriate.

 Now I see that setting the window position on the already constructed
 Dialog object does not have any effect, the only way I can actually
 set the position is by setting the position after construction, i.e.
 before the dialog gets rendered for the first time. I actually found
 this by trial-and-error, and the (rather terse) WiQuery documentation
 does not give me much more of a hint.

 Thus asking you - is there a way to reposition a reused dialog? If
 yes, how? It seems so weird I did not find anything on this because
 this requirement seems fairly typical to me...

 Cheers,

 Martin

 --
 -- mdie...@gmail.com --/-- mar...@the-little-red-haired-girl.org
 
 - / http://herbert.the-little-red-haired-girl.org /
 -

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




WiQuery: positioning a dialog when reusing it

2014-08-15 Thread Martin Dietze
In my application I am using WiQuery's 'Dialog' for a global page
dialog that gets constructed in my page base class. Each time I want
to show a dialog I embed a different panel in it and then show it.

Usually I would like to display smaller dialogs that fit on the screen
using WindowPosition.CENTER while for larger (i.e. longer) dialogs
WindowPosition.TOP would be more appropriate.

Now I see that setting the window position on the already constructed
Dialog object does not have any effect, the only way I can actually
set the position is by setting the position after construction, i.e.
before the dialog gets rendered for the first time. I actually found
this by trial-and-error, and the (rather terse) WiQuery documentation
does not give me much more of a hint.

Thus asking you - is there a way to reposition a reused dialog? If
yes, how? It seems so weird I did not find anything on this because
this requirement seems fairly typical to me...

Cheers,

Martin

-- 
-- mdie...@gmail.com --/-- mar...@the-little-red-haired-girl.org 
- / http://herbert.the-little-red-haired-girl.org / -

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org