Re: Support for optgroup ?

2014-06-05 Thread Thies Edeling
thanks!


On Thu, Jun 5, 2014 at 1:48 AM, Martin Makundi 
martin.maku...@koodaripalvelut.com wrote:

 Look at:


 http://mail-archives.apache.org/mod_mbox/wicket-users/200912.mbox/%3c303141550912040641r1e00841dudaacfefda9497...@mail.gmail.com%3E


 2014-06-05 1:41 GMT+03:00 Thies Edeling tedel...@gmail.com:

  Is there any support for optgroup's in Wicket? I can only find some
  examples using ListView's and other hacky solutions so I'm guessing there
  isn't :) Thanks !
 
  gr
  Thies
 



Re: Support for optgroup ?

2014-06-05 Thread Martin Makundi
The optgroup code might be buggy, here is a fresh one:

  private String previouslyAppendedOptGroupLabel;
  private int choices;

  /**
   * @see
org.apache.wicket.markup.html.form.AbstractChoice#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
org.apache.wicket.markup.ComponentTag)
   */
  @Override
  protected void onComponentTagBody(MarkupStream markupStream,
  ComponentTag openTag) {
previouslyAppendedOptGroupLabel = null;
choices = getChoices().size();
super.onComponentTagBody(markupStream, openTag);
  }


/**
   * @see
org.apache.wicket.markup.html.form.AbstractChoice#appendOptionHtml(org.apache.wicket.util.string.AppendingStringBuffer,
java.lang.Object, int, java.lang.String)
   */
  @Override
  protected void appendOptionHtml(AppendingStringBuffer buffer, T choice,
  int index, String selected) {
AppendingStringBuffer tmp = new AppendingStringBuffer(50);
super.appendOptionHtml(tmp, choice, index, selected);

if (getChoiceRenderer() instanceof IStyledChoiceRenderer) {
  IStyledChoiceRendererT styledChoiceRenderer =
(IStyledChoiceRendererT) getChoiceRenderer();

  String currentOptGroupLabel =
styledChoiceRenderer.getOptGroupLabel(choice);

  if (!Utils.equalsOrNull(currentOptGroupLabel,
previouslyAppendedOptGroupLabel)) {
// OptGroup changed
if (previouslyAppendedOptGroupLabel != null) {
  endOptGroup(buffer);
}

if (currentOptGroupLabel != null) {
  // OptGroup started
  int start = tmp.indexOf(option);
  StringBuilder label = new
StringBuilder(currentOptGroupLabel.length() + 19);
  label.append(optgroup
label=\).append(currentOptGroupLabel).append(\);
  tmp.insert(start, label);
}
  }

  if ((currentOptGroupLabel != null)  (index == (choices-1))) {
// Last option group must end too
endOptGroup(tmp);
  }

  {
String cssClass =
styledChoiceRenderer.getOptionCssClassName(choice);
if (cssClass != null) {
  int start = tmp.indexOf(option);
  tmp.insert(start + 7, getClass(cssClass));
}
  }

  previouslyAppendedOptGroupLabel = currentOptGroupLabel;
}

buffer.append(tmp);
  }

  /**
   * @param cssClass
   * @return StringBuilder
   */
  private StringBuilder getClass(String cssClass) {
return new StringBuilder( class=\).append(cssClass).append(\);
  }

  /**
   * @see
org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getDefaultChoice(java.lang.Object)
   */
  @Override
  protected CharSequence getDefaultChoice(Object selected) {
CharSequence charSequence = super.getDefaultChoice(selected);

if (charSequence.toString().contains(TOKEN)  (getChoiceRenderer()
instanceof IStyledChoiceRenderer)) {
  AppendingStringBuffer buffer = new
AppendingStringBuffer(charSequence);
  IStyledChoiceRendererT styledChoiceRenderer =
(IStyledChoiceRendererT) getChoiceRenderer();
  String cssClass = styledChoiceRenderer.getOptionCssClassName(null);
  if (!Utils.isEmpty(cssClass)) {
buffer.insert(buffer.indexOf(TOKEN), getClass(cssClass));
return buffer;
  }
}

return charSequence;
  }

  /**
   * @param tmp
   */
  private void endOptGroup(AppendingStringBuffer tmp) {
// OptGroup ended
int start = tmp.lastIndexOf(/option);
tmp.insert(start + 9, /optgroup);
  }


2014-06-05 9:37 GMT+03:00 Thies Edeling tedel...@gmail.com:

 thanks!


 On Thu, Jun 5, 2014 at 1:48 AM, Martin Makundi 
 martin.maku...@koodaripalvelut.com wrote:

  Look at:
 
 
 
 http://mail-archives.apache.org/mod_mbox/wicket-users/200912.mbox/%3c303141550912040641r1e00841dudaacfefda9497...@mail.gmail.com%3E
 
 
  2014-06-05 1:41 GMT+03:00 Thies Edeling tedel...@gmail.com:
 
   Is there any support for optgroup's in Wicket? I can only find some
   examples using ListView's and other hacky solutions so I'm guessing
 there
   isn't :) Thanks !
  
   gr
   Thies
  
 



Re: Support for optgroup ?

2014-06-05 Thread Martin Makundi
Ah.. and token was:
  private static final String TOKEN =  value=\\;



2014-06-05 9:42 GMT+03:00 Martin Makundi martin.maku...@koodaripalvelut.com
:

 The optgroup code might be buggy, here is a fresh one:

   private String previouslyAppendedOptGroupLabel;
   private int choices;

   /**
* @see
 org.apache.wicket.markup.html.form.AbstractChoice#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
 org.apache.wicket.markup.ComponentTag)
*/
   @Override
   protected void onComponentTagBody(MarkupStream markupStream,
   ComponentTag openTag) {
 previouslyAppendedOptGroupLabel = null;
 choices = getChoices().size();
 super.onComponentTagBody(markupStream, openTag);
   }


 /**
* @see
 org.apache.wicket.markup.html.form.AbstractChoice#appendOptionHtml(org.apache.wicket.util.string.AppendingStringBuffer,
 java.lang.Object, int, java.lang.String)
*/
   @Override
   protected void appendOptionHtml(AppendingStringBuffer buffer, T choice,
   int index, String selected) {
 AppendingStringBuffer tmp = new AppendingStringBuffer(50);
 super.appendOptionHtml(tmp, choice, index, selected);

 if (getChoiceRenderer() instanceof IStyledChoiceRenderer) {
   IStyledChoiceRendererT styledChoiceRenderer =
 (IStyledChoiceRendererT) getChoiceRenderer();

   String currentOptGroupLabel =
 styledChoiceRenderer.getOptGroupLabel(choice);

   if (!Utils.equalsOrNull(currentOptGroupLabel,
 previouslyAppendedOptGroupLabel)) {
 // OptGroup changed
 if (previouslyAppendedOptGroupLabel != null) {
   endOptGroup(buffer);
 }

 if (currentOptGroupLabel != null) {
   // OptGroup started
   int start = tmp.indexOf(option);
   StringBuilder label = new
 StringBuilder(currentOptGroupLabel.length() + 19);
   label.append(optgroup
 label=\).append(currentOptGroupLabel).append(\);
   tmp.insert(start, label);
 }
   }

   if ((currentOptGroupLabel != null)  (index == (choices-1))) {
 // Last option group must end too
 endOptGroup(tmp);
   }

   {
 String cssClass =
 styledChoiceRenderer.getOptionCssClassName(choice);
 if (cssClass != null) {
   int start = tmp.indexOf(option);
   tmp.insert(start + 7, getClass(cssClass));
 }
   }

   previouslyAppendedOptGroupLabel = currentOptGroupLabel;
 }

 buffer.append(tmp);
   }

   /**
* @param cssClass
* @return StringBuilder
*/
   private StringBuilder getClass(String cssClass) {
 return new StringBuilder( class=\).append(cssClass).append(\);
   }

   /**
* @see
 org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getDefaultChoice(java.lang.Object)
*/
   @Override
   protected CharSequence getDefaultChoice(Object selected) {
 CharSequence charSequence = super.getDefaultChoice(selected);

 if (charSequence.toString().contains(TOKEN)  (getChoiceRenderer()
 instanceof IStyledChoiceRenderer)) {
   AppendingStringBuffer buffer = new
 AppendingStringBuffer(charSequence);
   IStyledChoiceRendererT styledChoiceRenderer =
 (IStyledChoiceRendererT) getChoiceRenderer();
   String cssClass = styledChoiceRenderer.getOptionCssClassName(null);
   if (!Utils.isEmpty(cssClass)) {
 buffer.insert(buffer.indexOf(TOKEN), getClass(cssClass));
 return buffer;
   }
 }

 return charSequence;
   }

   /**
* @param tmp
*/
   private void endOptGroup(AppendingStringBuffer tmp) {
 // OptGroup ended
 int start = tmp.lastIndexOf(/option);
 tmp.insert(start + 9, /optgroup);
   }


 2014-06-05 9:37 GMT+03:00 Thies Edeling tedel...@gmail.com:

 thanks!


 On Thu, Jun 5, 2014 at 1:48 AM, Martin Makundi 
 martin.maku...@koodaripalvelut.com wrote:

  Look at:
 
 
 
 http://mail-archives.apache.org/mod_mbox/wicket-users/200912.mbox/%3c303141550912040641r1e00841dudaacfefda9497...@mail.gmail.com%3E
 
 
  2014-06-05 1:41 GMT+03:00 Thies Edeling tedel...@gmail.com:
 
   Is there any support for optgroup's in Wicket? I can only find some
   examples using ListView's and other hacky solutions so I'm guessing
 there
   isn't :) Thanks !
  
   gr
   Thies
  
 





Re: How to Embed PDF in a Web Page

2014-06-05 Thread rsi610
I am trying to achieve embedding pdf in a web page using Wicket.I am stuck
deciding whether to use Downloadlink or resourceLink .Can someone please
explain me the difference and also help me in embedding the web page ?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-Embed-PDF-in-a-Web-Page-tp1853387p4666139.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: How to Embed PDF in a Web Page

2014-06-05 Thread Martin Grigorov
Hi,

You need to use ResourceLink because you need Content-Disposition: Inline
response header to tell the browser to *try* to render the pdf.
With DownloadLink it will be Content-Disposition: Download and the
browser will popup a confirm dialog to the user asking her where to store
the file.

But to work the browser needs to know how to render PDFs (either out of the
box, or with a plugin). If there is no such support then the browser will
offer to download the file.

Martin Grigorov
Wicket Training and Consulting


On Thu, Jun 5, 2014 at 10:02 AM, rsi610 rahul.i...@lntinfotech.com wrote:

 I am trying to achieve embedding pdf in a web page using Wicket.I am stuck
 deciding whether to use Downloadlink or resourceLink .Can someone please
 explain me the difference and also help me in embedding the web page ?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/How-to-Embed-PDF-in-a-Web-Page-tp1853387p4666139.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: Support for optgroup ?

2014-06-05 Thread Thies Edeling
I just noticed, thanks for the update !


On Thu, Jun 5, 2014 at 8:45 AM, Martin Makundi 
martin.maku...@koodaripalvelut.com wrote:

 Ah.. and token was:
   private static final String TOKEN =  value=\\;



 2014-06-05 9:42 GMT+03:00 Martin Makundi 
 martin.maku...@koodaripalvelut.com
 :

  The optgroup code might be buggy, here is a fresh one:
 
private String previouslyAppendedOptGroupLabel;
private int choices;
 
/**
 * @see
 
 org.apache.wicket.markup.html.form.AbstractChoice#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
  org.apache.wicket.markup.ComponentTag)
 */
@Override
protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
  previouslyAppendedOptGroupLabel = null;
  choices = getChoices().size();
  super.onComponentTagBody(markupStream, openTag);
}
 
 
  /**
 * @see
 
 org.apache.wicket.markup.html.form.AbstractChoice#appendOptionHtml(org.apache.wicket.util.string.AppendingStringBuffer,
  java.lang.Object, int, java.lang.String)
 */
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, T choice,
int index, String selected) {
  AppendingStringBuffer tmp = new AppendingStringBuffer(50);
  super.appendOptionHtml(tmp, choice, index, selected);
 
  if (getChoiceRenderer() instanceof IStyledChoiceRenderer) {
IStyledChoiceRendererT styledChoiceRenderer =
  (IStyledChoiceRendererT) getChoiceRenderer();
 
String currentOptGroupLabel =
  styledChoiceRenderer.getOptGroupLabel(choice);
 
if (!Utils.equalsOrNull(currentOptGroupLabel,
  previouslyAppendedOptGroupLabel)) {
  // OptGroup changed
  if (previouslyAppendedOptGroupLabel != null) {
endOptGroup(buffer);
  }
 
  if (currentOptGroupLabel != null) {
// OptGroup started
int start = tmp.indexOf(option);
StringBuilder label = new
  StringBuilder(currentOptGroupLabel.length() + 19);
label.append(optgroup
  label=\).append(currentOptGroupLabel).append(\);
tmp.insert(start, label);
  }
}
 
if ((currentOptGroupLabel != null)  (index == (choices-1))) {
  // Last option group must end too
  endOptGroup(tmp);
}
 
{
  String cssClass =
  styledChoiceRenderer.getOptionCssClassName(choice);
  if (cssClass != null) {
int start = tmp.indexOf(option);
tmp.insert(start + 7, getClass(cssClass));
  }
}
 
previouslyAppendedOptGroupLabel = currentOptGroupLabel;
  }
 
  buffer.append(tmp);
}
 
/**
 * @param cssClass
 * @return StringBuilder
 */
private StringBuilder getClass(String cssClass) {
  return new StringBuilder( class=\).append(cssClass).append(\);
}
 
/**
 * @see
 
 org.apache.wicket.markup.html.form.AbstractSingleSelectChoice#getDefaultChoice(java.lang.Object)
 */
@Override
protected CharSequence getDefaultChoice(Object selected) {
  CharSequence charSequence = super.getDefaultChoice(selected);
 
  if (charSequence.toString().contains(TOKEN)  (getChoiceRenderer()
  instanceof IStyledChoiceRenderer)) {
AppendingStringBuffer buffer = new
  AppendingStringBuffer(charSequence);
IStyledChoiceRendererT styledChoiceRenderer =
  (IStyledChoiceRendererT) getChoiceRenderer();
String cssClass = styledChoiceRenderer.getOptionCssClassName(null);
if (!Utils.isEmpty(cssClass)) {
  buffer.insert(buffer.indexOf(TOKEN), getClass(cssClass));
  return buffer;
}
  }
 
  return charSequence;
}
 
/**
 * @param tmp
 */
private void endOptGroup(AppendingStringBuffer tmp) {
  // OptGroup ended
  int start = tmp.lastIndexOf(/option);
  tmp.insert(start + 9, /optgroup);
}
 
 
  2014-06-05 9:37 GMT+03:00 Thies Edeling tedel...@gmail.com:
 
  thanks!
 
 
  On Thu, Jun 5, 2014 at 1:48 AM, Martin Makundi 
  martin.maku...@koodaripalvelut.com wrote:
 
   Look at:
  
  
  
 
 http://mail-archives.apache.org/mod_mbox/wicket-users/200912.mbox/%3c303141550912040641r1e00841dudaacfefda9497...@mail.gmail.com%3E
  
  
   2014-06-05 1:41 GMT+03:00 Thies Edeling tedel...@gmail.com:
  
Is there any support for optgroup's in Wicket? I can only find some
examples using ListView's and other hacky solutions so I'm guessing
  there
isn't :) Thanks !
   
gr
Thies
   
  
 
 
 



Re: How to Embed PDF in a Web Page

2014-06-05 Thread Ernesto Reinaldo Barreiro
This might also be of some help

https://github.com/reiern70/antilia-bits/tree/master/content-iframe/src/main/java/com/antilia


On Thu, Jun 5, 2014 at 10:02 AM, rsi610 rahul.i...@lntinfotech.com wrote:

 I am trying to achieve embedding pdf in a web page using Wicket.I am stuck
 deciding whether to use Downloadlink or resourceLink .Can someone please
 explain me the difference and also help me in embedding the web page ?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/How-to-Embed-PDF-in-a-Web-Page-tp1853387p4666139.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


Google Application Security program

2014-06-05 Thread Martin Grigorov
Hi,

Google have added Wicket to the list of frameworks and libraries which are
applicable for a program that rewards proactive security improvements [1].

If you find any security related problem in Wicket please send it to us at
priv...@wicket.apache.org and once the fix is applied you can reach Google
at security-patc...@google.com for your payment! ;-)


1. http://www.google.com/about/appsecurity/patch-rewards/


Martin Grigorov
Wicket Training and Consulting


OnChangeAjaxBehavior.onUpdate() not called

2014-06-05 Thread Lucio Crusca
I need to make a calculator like this:

input text field x some fixed float value = the result
input text field x some other fixed float value = the other result
... and so on for a variable number of rows...

I need the user to input a number in one of the input text fields.
I need the other input text fields to update themselves while the user types 
the number digits, so that all input fields show exactly the same number at any 
time.
I need the results to update themselves also while the user types the digits.

here is my html snippet

wicket:container wiker:id=repeating
input name=num type=text wicket:id=num value=10,00/input
x
span wicket:id=fixed5.2/span
=
span name=total wicket:id=total52/span
/wicket:container

and Java code:

Label fixed = new Label(fixed, myFixedNumber);
add(fixed);

final TextField input = new TextField(input);
add(input);
input.add(new OnChangeAjaxBehavior()
{
  @Override
  protected void onUpdate(AjaxRequestTarget target)
  {
// this never gets called
  }
});
   
Label total = new Label(total);
add(total);

The problem is that onUpdate() never gets called. Please note that I'm not 
using any form because I do not need any (I don't need the user to submit 
anything), but I need to make calculations server side because the fixed value 
is known there.

Is it possible to have onUpdate() called without using a form? if yes, what am 
I doing wrong?



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



Re: OnChangeAjaxBehavior.onUpdate() not called

2014-06-05 Thread Martin Grigorov
Hi,


On Thu, Jun 5, 2014 at 9:26 PM, Lucio Crusca lu...@sulweb.org wrote:

 I need to make a calculator like this:

 input text field x some fixed float value = the result
 input text field x some other fixed float value = the other result
 ... and so on for a variable number of rows...

 I need the user to input a number in one of the input text fields.
 I need the other input text fields to update themselves while the user
 types
 the number digits, so that all input fields show exactly the same number
 at any
 time.
 I need the results to update themselves also while the user types the
 digits.

 here is my html snippet

 wicket:container wiker:id=repeating
 input name=num type=text wicket:id=num value=10,00/input


remove the name attribute. Wicket will assign one automatically


 x
 span wicket:id=fixed5.2/span
 =
 span name=total wicket:id=total52/span
 /wicket:container

 and Java code:

 Label fixed = new Label(fixed, myFixedNumber);
 add(fixed);

 final TextField input = new TextField(input);
 add(input);
 input.add(new OnChangeAjaxBehavior()
 {
   @Override
   protected void onUpdate(AjaxRequestTarget target)
   {
 // this never gets called
   }
 });

 Label total = new Label(total);
 add(total);

 The problem is that onUpdate() never gets called. Please note that I'm not
 using any form because I do not need any (I don't need the user to submit
 anything), but I need to make calculations server side because the fixed
 value
 is known there.

 Is it possible to have onUpdate() called without using a form? if yes,
 what am
 I doing wrong?


everything looks OK to me
check whether there are any JS errors in the browser's Dev Tools console.





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