Re: Hybrid palette with DropDownChoice and ListView

2014-02-14 Thread ChambreNoire
OK so this is what I have so far. Seems to work OK.

public class DropDownPalette extends FormComponentPanel {

private static final String UNSELECTED_ID = "unselected";
private static final String SELECT_ACTION_ID = "select";
private static final String SELECTED_ID = "selected";
private static final String SELECTED_NAME_ID = "selected_name";
private static final String UNSELECT_ID = "unselect";

private IModel choicesModel;
private IChoiceRenderer choiceRenderer;

private transient List selectedChoices;
private transient List unselectedChoices;

private String[] ids;

public DropDownPalette(String id, IModel model, IModel choicesModel,
IChoiceRenderer choiceRenderer) {
super(id, model);

setOutputMarkupId(true);

this.choicesModel = choicesModel;
this.choiceRenderer = choiceRenderer;

IModel unselectedChoices = new LoadableDetachableModel() {

@Override
protected Object load() {

return getUnselectedChoices();
}
};

DropDownChoice choice = new DropDownChoice(UNSELECTED_ID, new
Model(), unselectedChoices, choiceRenderer);

choice.add(new OnChangeAjaxBehavior() {

@Override
protected void onUpdate(AjaxRequestTarget target) {

target.addComponent(DropDownPalette.this);
}
});

add(choice);

add(new AjaxLink(SELECT_ACTION_ID) {

@Override
public void onClick(AjaxRequestTarget target) {

getModelCollection().add(getCurrentChoice());

setCurrentChoice(null);
initIds();

onItemSelected(target);

target.addComponent(DropDownPalette.this);
}

@SuppressWarnings("unchecked")
private T getCurrentChoice() {
return (T) getParent().get(UNSELECTED_ID).getModelObject();
}

private void setCurrentChoice(T choice) {
getParent().get(UNSELECTED_ID).setModelObject(choice);
}

@Override
protected void onBeforeRender() {

setVisibilityAllowed(getCurrentChoice() != null);
super.onBeforeRender();
}

@Override
protected boolean callOnBeforeRenderIfNotVisible() {
return true;
}
});

IModel selectedChoices = new AbstractReadOnlyModel() {

@Override
public Object getObject() {
return getSelectedChoices();
}
};

add(new ListView(SELECTED_ID, selectedChoices) {

@Override
protected void populateItem(ListItem item) {

Object displayValue =
getChoiceRenderer().getDisplayValue(item.getModelObject());

item.add(new Label(SELECTED_NAME_ID, new
Model(String.valueOf(displayValue;

item.add(new AjaxLink(UNSELECT_ID) {

@Override
@SuppressWarnings("SuspiciousMethodCalls")
public void onClick(AjaxRequestTarget target) {

   
getModelCollection().remove(getParent().getModelObject());

flushSelectedChoices(); // in order to reload the
choices

onItemUnselected(target);

target.addComponent(DropDownPalette.this);
}
});
}
});
}

protected void onItemUnselected(AjaxRequestTarget target) {}

protected void onItemSelected(AjaxRequestTarget target) {}

@Override
protected void convertInput() {
setConvertedInput(getSelectedChoices());
}

protected void onBeforeRender() {

if (!getForm().hasError()) {
initIds();
}
super.onBeforeRender();
}

@SuppressWarnings("unchecked")
public List getSelectedChoices() {

if (selectedChoices == null) {

IChoiceRenderer renderer = getChoiceRenderer();

if (ids.length == 0) {
return Collections.EMPTY_LIST;
}

selectedChoices = new ArrayList(ids.length);

for (String id : ids) {

for (T choice : getChoices()) {

if (renderer.getIdValue(choice, 0).equals(id)) {

selectedChoices.add(choice);
break;
}
}
}
}
return selectedChoices;
}

@SuppressWarnings("unchecked")
public List getUnselectedChoices() {

if (unselectedChoices == null) {

Collection choices = getChoices();

if (choices.size() - ids.length == 0) {
return Collections.EMPTY_LIST;
}

unselectedChoices = new ArrayList(Math.max(1, choices.size()
- ids.length));

   

Session size vs detached models

2014-02-14 Thread Daniel Stoch
Hi,

In Wicket 1.4 the last page reference is hold in a session (is it in 6.x
also?). So after a request has been processed all components and models
should be detached, so this last page reference should not hold transient
LDM values. Is it true?

When we are using DebugBar with SessionSizeDebugPanel, it displays session
size and totalSize (by SessionTotalSizeModel). Does this totalSize includes
size of object loaded by LDM or it counts all components and models size in
detached state?

--
Daniel


Re: Session size vs detached models

2014-02-14 Thread Martin Grigorov
Hi,

On Fri, Feb 14, 2014 at 3:55 PM, Daniel Stoch wrote:

> Hi,
>
> In Wicket 1.4 the last page reference is hold in a session (is it in 6.x
> also?). So after a request has been processed all components and models
>

Yes. A live instance of the last used page is kept in the http session.
Actually it is a list of page instances.
All instantiated and "touched" pages in a request are saved for faster
retrieval for the next request.
https://cwiki.apache.org/confluence/display/WICKET/Page+Storage


> should be detached, so this last page reference should not hold transient
> LDM values. Is it true?
>

LDM null-yfies its transien field explicitly:
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java?source=cc#L104

But if your custom model uses transient that is not null-yfied in
onDetach() then it will be kept alive in the http session.


>
> When we are using DebugBar with SessionSizeDebugPanel, it displays session
> size and totalSize (by SessionTotalSizeModel). Does this totalSize includes
> size of object loaded by LDM or it counts all components and models size in
> detached state?
>

I have to check what is th difference between size and totalSize, but since
https://issues.apache.org/jira/browse/WICKET-4867 the detachable is
detached before measuring its size.


>
> --
> Daniel
>


Re: Session size vs detached models

2014-02-14 Thread Daniel Stoch
On Fri, Feb 14, 2014 at 4:12 PM, Martin Grigorov wrote:

>
> > should be detached, so this last page reference should not hold transient
> > LDM values. Is it true?
> >
>
> LDM null-yfies its transien field explicitly:
>
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java?source=cc#L104
>
> But if your custom model uses transient that is not null-yfied in
> onDetach() then it will be kept alive in the http session.
>

You mean in detach(), not onDetach() ;)


>
> >
> > When we are using DebugBar with SessionSizeDebugPanel, it displays
> session
> > size and totalSize (by SessionTotalSizeModel). Does this totalSize
> includes
> > size of object loaded by LDM or it counts all components and models size
> in
> > detached state?
> >
>
> I have to check what is th difference between size and totalSize, but since
> https://issues.apache.org/jira/browse/WICKET-4867 the detachable is
> detached before measuring its size.
>
> Ok, great to know. So it looks in 1.4.x totalSize is measured before
detaching.


Thanks for the answer.

--
Daniel


factory method to create the DataGridView in DataTable

2014-02-14 Thread Dirk Germonpré
Hello,

I'm using the latest Wicket version (6).

I would like to see a factory method to create the DataGridView
(org.apache.wicket.extensions.markup.html.repeater.data.grid) in DataTable
(org.apache.wicket.extensions.markup.html.repeater.data.table).

I need this to be able to override some methods in the DataGridView.

More concrete: I use a TableTree and want to override methods
getFirstItemObject and getViewSize in AbstractPageableView, a superclass of
the DataGridView, which is used in the DataTable, which is used in the
TableTree.

How should I go about this? Do I have to submit a JIRA issue?

Kind regards,
Dirk Germonpré.


techniques using of Form

2014-02-14 Thread Farrukh SATTOROV
What is best practices to flexible use of Form: to do external subclass
MyForm, to do as instance MyForm inside Panel constructor or inner class of
MyForm inside Panel class ?


getting values from FormComponentPanel outside form.onSubmit()

2014-02-14 Thread lucast
Dear forum,

I have implemented a FormComponentPanel as suggested both in the Apache
Wicket Cookbook (chapter 2) and  wicket guide (chapter 12.8)
  .

Before I submit the form, I would like to have the option of adding the
content from FormComponentPanel to a list.

I have made use of AjaxButton and  I have set 
AjaxButton.setDefaultFormProcessing( false).

In order to get value from FormComponentPanel when performing 
form.onSubmit(), one calls FormComponentPanel.getConvertedInput(), which in
turns calls FormComponentPanel.convertInput().

The problem is that if I call FormComponentPanel.getConvertedInput() from
inside AjaxButton.onSubmit(), FormComponentPanel.convertInput() is never
called.

My question is, how can I get the contents from FormComponentPanel using a
AjaxSubmitLink or AjaxButton without having to go via form.onSubmit()?

Is there, perhaps another form component that I could use to achieve my
goal?

Thanks in advance,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/getting-values-from-FormComponentPanel-outside-form-onSubmit-tp4664462.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: techniques using of Form

2014-02-14 Thread lucast
Hi Farrukh,
>From existing literature (Wicket in Action, Apache wicket Cookbook,  wicket
guide   ), there are a
number of ways you can go about it.

You can put your form in a panel, have a submit once form (to prevent
multiple submits) as template and extend that class. It all depends on what
your needs are.

FormComponentPanels are also very useful.

I'm sure people in this forum have better and more extensive suggestions
than me but at least, that's a starter. 
Both the Apache wicket Cookbook and wicket guide are good starting points
for creating your own best practices.

I hope that helps,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/techniques-using-of-Form-tp4664459p4664463.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: techniques using of Form

2014-02-14 Thread Farrukh SATTOROV
thanks!, Lucas


On Fri, Feb 14, 2014 at 9:23 PM, lucast  wrote:

> Hi Farrukh,
> From existing literature (Wicket in Action, Apache wicket Cookbook,  wicket
> guide   ), there are a
> number of ways you can go about it.
>
> You can put your form in a panel, have a submit once form (to prevent
> multiple submits) as template and extend that class. It all depends on what
> your needs are.
>
> FormComponentPanels are also very useful.
>
> I'm sure people in this forum have better and more extensive suggestions
> than me but at least, that's a starter.
> Both the Apache wicket Cookbook and wicket guide are good starting points
> for creating your own best practices.
>
> I hope that helps,
> Lucas
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/techniques-using-of-Form-tp4664459p4664463.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
>
>


-- 
С уважением и наилучшими пожеланиями
*Фаррух*


understanding looking for wicket:id

2014-02-14 Thread Farrukh SATTOROV
Hi everyone. I confused when i look to standard wicket heloworld example
and try understanding  snippet of . How
HelloWorld.html works without  while id mainNavigation
located in superclass (WicketExamplePage). Explain to me mechanism of
looking for wicket:id in this case.


Re: understanding looking for wicket:id

2014-02-14 Thread Sven Meier
With a wicket:id declared in Html markup, a corresponding component with 
the same id has to present as child.


It doesn't matter when the child component is added: in the constructor 
or one of its super constructors (or even later).

This does not have anything to do with markup inheritance.

Hope this helps
Sven

On 02/14/2014 07:34 PM, Farrukh SATTOROV wrote:

Hi everyone. I confused when i look to standard wicket heloworld example
and try understanding  snippet of . How
HelloWorld.html works without  while id mainNavigation
located in superclass (WicketExamplePage). Explain to me mechanism of
looking for wicket:id in this case.




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



Re: getting values from FormComponentPanel outside form.onSubmit()

2014-02-14 Thread Sven Meier

FormComponentPanel.getConvertedInput(), which in turns calls 
FormComponentPanel.convertInput().


Not true.

See FormComponentPanel#onEvent() on how to properly process a single 
FormComponent.

Regards
Sven



On 02/14/2014 06:14 PM, lucast wrote:

Dear forum,

I have implemented a FormComponentPanel as suggested both in the Apache
Wicket Cookbook (chapter 2) and  wicket guide (chapter 12.8)
  .

Before I submit the form, I would like to have the option of adding the
content from FormComponentPanel to a list.

I have made use of AjaxButton and  I have set
AjaxButton.setDefaultFormProcessing( false).

In order to get value from FormComponentPanel when performing
form.onSubmit(), one calls FormComponentPanel.getConvertedInput(), which in
turns calls FormComponentPanel.convertInput().

The problem is that if I call FormComponentPanel.getConvertedInput() from
inside AjaxButton.onSubmit(), FormComponentPanel.convertInput() is never
called.

My question is, how can I get the contents from FormComponentPanel using a
AjaxSubmitLink or AjaxButton without having to go via form.onSubmit()?

Is there, perhaps another form component that I could use to achieve my
goal?

Thanks in advance,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/getting-values-from-FormComponentPanel-outside-form-onSubmit-tp4664462.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




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



Re: getting values from FormComponentPanel outside form.onSubmit()

2014-02-14 Thread Richter, Marvin
Why wouldn’t you just use the defaultFormProcessing an add the converted value 
of the FormComponentPanel to the list inside your onSubmit method?

Best,
Marvin


Am 14.02.2014 um 18:14 schrieb lucast :

> Dear forum,
> 
> I have implemented a FormComponentPanel as suggested both in the Apache
> Wicket Cookbook (chapter 2) and  wicket guide (chapter 12.8)
>   .
> 
> Before I submit the form, I would like to have the option of adding the
> content from FormComponentPanel to a list.
> 
> I have made use of AjaxButton and  I have set 
> AjaxButton.setDefaultFormProcessing( false).
> 
> In order to get value from FormComponentPanel when performing 
> form.onSubmit(), one calls FormComponentPanel.getConvertedInput(), which in
> turns calls FormComponentPanel.convertInput().
> 
> The problem is that if I call FormComponentPanel.getConvertedInput() from
> inside AjaxButton.onSubmit(), FormComponentPanel.convertInput() is never
> called.
> 
> My question is, how can I get the contents from FormComponentPanel using a
> AjaxSubmitLink or AjaxButton without having to go via form.onSubmit()?
> 
> Is there, perhaps another form component that I could use to achieve my
> goal?
> 
> Thanks in advance,
> Lucas
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/getting-values-from-FormComponentPanel-outside-form-onSubmit-tp4664462.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
> 


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



Re: understanding looking for wicket:id

2014-02-14 Thread Farrukh SATTOROV
my code work, if by definition each WebPage and Panel must have own markup
?

MyBasePage.java:
public class MyBasePage extends WebPage {

public MyBasePage() {
add(new MyPanel("panel"));
}
}

no MyBasePage.html, i remove it.

SubPage.java:
public class SubPage extends MyBasePage {
 public SubPage() {
}

}

SubPage.html:






MyPanel.html


MyPanel




On Fri, Feb 14, 2014 at 10:56 PM, Sven Meier  wrote:

> With a wicket:id declared in Html markup, a corresponding component with
> the same id has to present as child.
>
> It doesn't matter when the child component is added: in the constructor or
> one of its super constructors (or even later).
> This does not have anything to do with markup inheritance.
>
> Hope this helps
> Sven
>
>
> On 02/14/2014 07:34 PM, Farrukh SATTOROV wrote:
>
>> Hi everyone. I confused when i look to standard wicket heloworld example
>> and try understanding  snippet of . How
>> HelloWorld.html works without  while id mainNavigation
>> located in superclass (WicketExamplePage). Explain to me mechanism of
>> looking for wicket:id in this case.
>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
С уважением и наилучшими пожеланиями
*Фаррух*


Re: understanding looking for wicket:id

2014-02-14 Thread Richter, Marvin
That is definitely not a good way to do inheritance. This way you force 
everyone who extends from MyBasePage to know that he has to have a tag in his 
markup file with a wicket:id he might not know.

The right way would be to have a markup file for MyBasePage.java and include 
the  tag.

MyBasePage.html


 }
> }
> 
> no MyBasePage.html, i remove it.
> 
> SubPage.java:
> public class SubPage extends MyBasePage {
> public SubPage() {
> }
> 
> }
> 
> SubPage.html:
> 
> 
> 
> 
> 
> 
> MyPanel.html
> 
> 
> MyPanel
> 
> 
> 
> 
> On Fri, Feb 14, 2014 at 10:56 PM, Sven Meier  wrote:
> 
>> With a wicket:id declared in Html markup, a corresponding component with
>> the same id has to present as child.
>> 
>> It doesn't matter when the child component is added: in the constructor or
>> one of its super constructors (or even later).
>> This does not have anything to do with markup inheritance.
>> 
>> Hope this helps
>> Sven
>> 
>> 
>> On 02/14/2014 07:34 PM, Farrukh SATTOROV wrote:
>> 
>>> Hi everyone. I confused when i look to standard wicket heloworld example
>>> and try understanding  snippet of . How
>>> HelloWorld.html works without  while id mainNavigation
>>> located in superclass (WicketExamplePage). Explain to me mechanism of
>>> looking for wicket:id in this case.
>>> 
>>> 
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
>> 
> 
> 
> -- 
> С уважением и наилучшими пожеланиями
> *Фаррух*


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



Leaving page after closing modal results in browser pop up

2014-02-14 Thread PDiefent
Hi,
with the current Wicket 6.13.0 I got a new problem. When leaving a page
after openin a modal window results in a browser pop up where I have to
confirm leaving the page. If I leave the page without opening the modal
window the browser doesn't request a confirmation.

Any suggestions?

Thanks, Peter 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Leaving-page-after-closing-modal-results-in-browser-pop-up-tp4664471.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



Jetty, Wicket and getting live JavaScript changes?

2014-02-14 Thread tertioptus
I use Jetty, maven and Eclipse.

*What's the best way for me to have Jetty pick up my changes from a
JavaScript file not in the war project?*

Currently, I have clean install both projects and then restart jetty to see
changes.

I am assuming this is common among Wicket users with the advent of component
bound resources.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Jetty-Wicket-and-getting-live-JavaScript-changes-tp4664472.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: Leaving page after closing modal results in browser pop up

2014-02-14 Thread Ernesto Reinaldo Barreiro
Hi,

Did you try ModalWindow#showUnloadConfirmation?


On Fri, Feb 14, 2014 at 11:03 PM, PDiefent  wrote:

> Hi,
> with the current Wicket 6.13.0 I got a new problem. When leaving a page
> after openin a modal window results in a browser pop up where I have to
> confirm leaving the page. If I leave the page without opening the modal
> window the browser doesn't request a confirmation.
>
> Any suggestions?
>
> Thanks, Peter
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Leaving-page-after-closing-modal-results-in-browser-pop-up-tp4664471.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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro