Wicket 1.4.2 Released!

2009-10-10 Thread Igor Vaynberg
The Apache Wicket project is proud to announce the second maintenance
release of Apache Wicket 1.4.

Download Apache Wicket 1.4
---

You can download the release here:
http://www.apache.org/dyn/closer.cgi/wicket/1.4.2

Or use this in your Maven pom's to upgrade to the new version:

dependency
  groupIdorg.apache.wicket/groupId
  artifactIdwicket/artifactId
  version1.4.2/version
/dependency

Release Notes - Wicket - Version 1.4.2

** Bug
  * [WICKET-2393] - Passwords should not be trimmed
  * [WICKET-2430] - Malformed \u encoding in
MultipleUploadField_sl.properties
  * [WICKET-2433] - Ajax support for multipart forms broken in a nested form
  * [WICKET-2434] - RequestCycle urlFor ignores existing parameters
when appending provided params
  * [WICKET-2436] - invalid DataTable markup breaks table layout
  * [WICKET-2438] - AjaxEventBehavior not working on feedback
message components
  * [WICKET-2453] - Form.findForm(Component c) bug. When form is
part of Border and form component like TextField is inside another
Border , component cannot resolve its form.
  * [WICKET-2456] - DateTextField cannot work with default converter
(or javadoc wrong)
  * [WICKET-2457] - Flash/ExternalInterface does not work in IE if
movie is fetched via Wicket/Ajax
  * [WICKET-2458] - JavascriptUtils.escapeQuotes() misses escaping
double quotes
  * [WICKET-2461] - AjaxPagingNavigationIncrementLink does not work
without AjaxPagingNavigator component
  * [WICKET-2463] - Ajax miltipart form submitting ignores
setDefaultFormProcessing(false)
  * [WICKET-2466] - javadoc the CryptedUrlWebRequestCodingStrategy
needs to be update/corrected to reflect the usage of session-id for
encryption and hence URLs which were bookmarkable before will NOT
remain bookmarkable.
  * [WICKET-2475] - NPE after application hot redeployment
  * [WICKET-2477] - AjaxEditableChoiceLabel does not detach choices model
  * [WICKET-2478] - TabbedPanel rendering bug
  * [WICKET-2485] - IComponentResolvers are not supported inside
wicket:enclosure
  * [WICKET-2488] - QuickFix proposal
WicketTesterHelper.assertEquals(final Collection? expects, final
Collection? actuals) should compare list sizes

** Improvement
  * [WICKET-626] - profile Wicket for 1.4.0
  * [WICKET-2435] - TabbedPanel extract factory method for tabs-container
  * [WICKET-2439] - Improve MixedParamUrlCodingStrategy, introduce Hybrid
  * [WICKET-2444] - Internal Spring beans should be ignored
  * [WICKET-2445] - FormInput.java needs the validators updated.
  * [WICKET-2449] - Fix javadoc biggest mistakes - mainly @Deprecated tags
  * [WICKET-2454] - IE8: be more verbose if ajax refresh fails
  * [WICKET-2469] - Allow using a different FileItemFactory by
extracting a method in MultipartServletWebRequest class
  * [WICKET-2492] - Application_pt_BR.properties path

** New Feature
  * [WICKET-2395] - add MixedParamHybridUrlCodingStrategy
  * [WICKET-2483] - Access to WizardModel.conditions

** Wish
  * [WICKET-2120] - widen visibiliy of GuiceProxyTargetLocator  and
findBindingAnnotation
  * [WICKET-2462] - Would it possible add chinese resource label for
WizardButton eg. CancelButton, NextButton and PreviousButton etc.
  * [WICKET-2489] - need to know if a component has been added to
the AjaxRequestTarget

We thank you for your patience and support.

The Wicket Team

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



commit access for wicket stuff

2009-10-10 Thread danisevsky
Hi,

I would like commit access for wicket stuff.
I plan working on YUI.

My sourceforge user name is danisevsky

Regards,


Re: Wicket 1.4.2 Released!

2009-10-10 Thread Anton Veretennikov
Congratulations! This is a great news for all wicket lovers!

-- Tony

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



Re: [tinymce] problem adding/removing TinyMceBehavior dinamically

2009-10-10 Thread Daniele Dellafiore
yep I do that. Actually, I wrote that article :)

My problem is more subtle here and I have discovered now that is
related to javascript execution order. In fact I open a new thread to
investigate that specific issue. I also try to produce a ExamplePage
to commit on tinymce example project.

On Fri, Oct 9, 2009 at 7:47 PM, Dane Laverty danelave...@gmail.com wrote:
 Did you get the
 response.renderJavascriptReference(TinyMCESettings.javaScriptReference()); ?

 In my code it goes like this (as per
 http://wicketbyexample.com/wicket-tinymce-some-advanced-tips/):

 add(new HeaderContributor(new IHeaderContributor() {
             public void renderHead(IHeaderResponse response) {

 response.renderJavascriptReference(TinyMCESettings.javaScriptReference());
             }
        }));

 Dane

 On Fri, Oct 9, 2009 at 10:17 AM, Daniele Dellafiore ilde...@gmail.comwrote:

 I start from the end: I need fine control over the order javascript is
 executed. What is the javascript to call a refresh on a component like
 is done when I use target.addComponent()?


 From the start.
 I make that work with bgooren suggestion, using the javascript to
 remove the editor. No need to remove the behavior on java side. That
 works for the checkbox that dynamically adds and removes the Rich
 Editor.

 Now, the problem on refreshing a list of fields.
 What happens: to add a new field, click on ADD and I add my ListView
 is added to be refreshed via a target.addComponent(). In doing this,
 the markupId of the component changes, so tinyMce lose reference to
 it's existing editors.

 My solution: on the ADD callback, I remove the editors and let them be
 re-added during repainting. Works? NO!
 Why? because the listView is repainted before the mceControlRemove is
 executed, even if they are added to the same AjaxRequestTarget in the
 ADD callback. So happens that:
 1.  the remove fails because the old component is found no more
 2. after, the submit fails because tinyMCE still have the old editor
 reference.

 -- ;(

 On Mon, Oct 5, 2009 at 11:44 AM, Daniele Dellafiore ilde...@gmail.com
 wrote:
  Hey Bas, thanks for answering.
 
  Unfortunately it does not work.
  Even if I run:
 
                String removeEditor =
 tinyMCE.execCommand('mceRemoveControl',
  false, '
                       + propertyPanel.getValueMarkupId() + ');;
                 target.appendJavascript(removeEditor);
 
  or simply remove the TinyMceBehavior from my TextField, the result is the
  same: mce editor disappear correclty, but remains in tinyMCE.editors list
 so
  Tiny tries to process it in a successive iteration.
 
  I try to find help on tinyMCE forum
 
 
  On Mon, Oct 5, 2009 at 10:59 AM, bgooren b...@iswd.nl wrote:
 
  I'll show you some parts of my code so you get an idea of how I do
 things.
 
  First of all, I have used AjaxEditableLabel from wicket-extensions as a
  starting point.
  TinyMCE's javascripts should always be loaded:
 
  // Preload TinyMCE
         add( new AbstractBehavior()
         {
 
            �...@override
             public void renderHead( IHeaderResponse response )
             {
                 if( !tinyMCELoaded )
                 {
                     response.renderJavascriptReference(
  TinyMCESettings.javaScriptReference() );
 
                     settings = buildTinyMCESettings();
 
                     tinyMCELoaded = true;
                 }
             }
 
         } );
 
  In my case TinyMCE is loaded through an AJAX call:
 
  @SuppressWarnings(unchecked)
    �...@override
     protected void onEdit( AjaxRequestTarget target )
     {
         super.onEdit( target );
 
         final String id = editor.getMarkupId( true );
         final StringBuilder buf = new StringBuilder();
 
         // Load plugins
         buf.append( settings.getLoadPluginJavaScript() ).append( ;\n );
 
         // Initialize tinyMCE
         buf.append( tinyMCE.init({ ).append( settings.toJavaScript(
  Mode.none, Collections.EMPTY_LIST ) ).append(  });\n );
         buf.append( settings.getAdditionalPluginJavaScript() ).append(
  ;\n
  );
 
         // Setup editor
         buf.append( tinyMCE.execCommand('mceAddControl',true,'
 ).append(
  id ).append( '); );
 
         // Request focus on editor
         buf.append( setTimeout( function()
  {tinyMCE.execCommand('mceFocus',true,' ).append( id ).append( ');},
 500
  ); );
 
         target.appendJavascript( buf.toString() );
     }
 
  As you can see I initialize TinyMCE, and then perform an mceAddControl
  command on the textarea I want to convert to a TinyMCE editor.
 
  Finally, I need to switch back to a textarea before unloading, so the
  correct contents are POSTed. To do so, I have added an AjaxCallDecorator
  to
  the close request, and allow implementations to override it:
 
  @Override
     protected IAjaxCallDecorator getCloseDecorator()
     {
         return new AjaxCallDecorator()
         {
 
            �...@override
             public CharSequence decorateScript( 

Re: Wicket 1.4.2 Released!

2009-10-10 Thread Giovanni
Wow!!!

I will upgrade my project for a major italian bank on coming monday.

Thanks a lot for all your efforts in developing this great web framework!

Best regards,
giovanni

 
Resources are limited, Imagination is unlimited.







From: Igor Vaynberg igor.vaynb...@gmail.com
To: users@wicket.apache.org; d...@wicket.apache.org; annou...@wicket.apache.org
Sent: Sat, October 10, 2009 8:27:47 AM
Subject: Wicket 1.4.2 Released!

The Apache Wicket project is proud to announce the second maintenance
release of Apache Wicket 1.4.

Download Apache Wicket 1.4
---

You can download the release here:
http://www.apache.org/dyn/closer.cgi/wicket/1.4.2

Or use this in your Maven pom's to upgrade to the new version:

dependency
  groupIdorg.apache.wicket/groupId
  artifactIdwicket/artifactId
  version1.4.2/version
/dependency

Release Notes - Wicket - Version 1.4.2

** Bug
  * [WICKET-2393] - Passwords should not be trimmed
  * [WICKET-2430] - Malformed \u encoding in
MultipleUploadField_sl.properties
  * [WICKET-2433] - Ajax support for multipart forms broken in a nested form
  * [WICKET-2434] - RequestCycle urlFor ignores existing parameters
when appending provided params
  * [WICKET-2436] - invalid DataTable markup breaks table layout
  * [WICKET-2438] - AjaxEventBehavior not working on feedback
message components
  * [WICKET-2453] - Form.findForm(Component c) bug. When form is
part of Border and form component like TextField is inside another
Border , component cannot resolve its form.
  * [WICKET-2456] - DateTextField cannot work with default converter
(or javadoc wrong)
  * [WICKET-2457] - Flash/ExternalInterface does not work in IE if
movie is fetched via Wicket/Ajax
  * [WICKET-2458] - JavascriptUtils.escapeQuotes() misses escaping
double quotes
  * [WICKET-2461] - AjaxPagingNavigationIncrementLink does not work
without AjaxPagingNavigator component
  * [WICKET-2463] - Ajax miltipart form submitting ignores
setDefaultFormProcessing(false)
  * [WICKET-2466] - javadoc the CryptedUrlWebRequestCodingStrategy
needs to be update/corrected to reflect the usage of session-id for
encryption and hence URLs which were bookmarkable before will NOT
remain bookmarkable.
  * [WICKET-2475] - NPE after application hot redeployment
  * [WICKET-2477] - AjaxEditableChoiceLabel does not detach choices model
  * [WICKET-2478] - TabbedPanel rendering bug
  * [WICKET-2485] - IComponentResolvers are not supported inside
wicket:enclosure
  * [WICKET-2488] - QuickFix proposal
WicketTesterHelper.assertEquals(final Collection? expects, final
Collection? actuals) should compare list sizes

** Improvement
  * [WICKET-626] - profile Wicket for 1.4.0
  * [WICKET-2435] - TabbedPanel extract factory method for tabs-container
  * [WICKET-2439] - Improve MixedParamUrlCodingStrategy, introduce Hybrid
  * [WICKET-2444] - Internal Spring beans should be ignored
  * [WICKET-2445] - FormInput.java needs the validators updated.
  * [WICKET-2449] - Fix javadoc biggest mistakes - mainly @Deprecated tags
  * [WICKET-2454] - IE8: be more verbose if ajax refresh fails
  * [WICKET-2469] - Allow using a different FileItemFactory by
extracting a method in MultipartServletWebRequest class
  * [WICKET-2492] - Application_pt_BR.properties path

** New Feature
  * [WICKET-2395] - add MixedParamHybridUrlCodingStrategy
  * [WICKET-2483] - Access to WizardModel.conditions

** Wish
  * [WICKET-2120] - widen visibiliy of GuiceProxyTargetLocator  and
findBindingAnnotation
  * [WICKET-2462] - Would it possible add chinese resource label for
WizardButton eg. CancelButton, NextButton and PreviousButton etc.
  * [WICKET-2489] - need to know if a component has been added to
the AjaxRequestTarget

We thank you for your patience and support.

The Wicket Team

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


  

Re: Wicket 1.4.2 Released!

2009-10-10 Thread Haulyn R. Jason
Congratulations, I will upgrade next week.

On Sat, Oct 10, 2009 at 8:05 PM, Giovanni pino_o...@yahoo.com wrote:

 Wow!!!

 I will upgrade my project for a major italian bank on coming monday.

 Thanks a lot for all your efforts in developing this great web framework!

 Best regards,
 giovanni

  
 Resources are limited, Imagination is unlimited.






 
 From: Igor Vaynberg igor.vaynb...@gmail.com
 To: users@wicket.apache.org; d...@wicket.apache.org;
 annou...@wicket.apache.org
 Sent: Sat, October 10, 2009 8:27:47 AM
 Subject: Wicket 1.4.2 Released!

 The Apache Wicket project is proud to announce the second maintenance
 release of Apache Wicket 1.4.

 Download Apache Wicket 1.4
 ---

 You can download the release here:
 http://www.apache.org/dyn/closer.cgi/wicket/1.4.2

 Or use this in your Maven pom's to upgrade to the new version:

 dependency
  groupIdorg.apache.wicket/groupId
  artifactIdwicket/artifactId
  version1.4.2/version
 /dependency

 Release Notes - Wicket - Version 1.4.2

 ** Bug
  * [WICKET-2393] - Passwords should not be trimmed
  * [WICKET-2430] - Malformed \u encoding in
 MultipleUploadField_sl.properties
  * [WICKET-2433] - Ajax support for multipart forms broken in a nested form
  * [WICKET-2434] - RequestCycle urlFor ignores existing parameters
 when appending provided params
  * [WICKET-2436] - invalid DataTable markup breaks table layout
  * [WICKET-2438] - AjaxEventBehavior not working on feedback
 message components
  * [WICKET-2453] - Form.findForm(Component c) bug. When form is
 part of Border and form component like TextField is inside another
 Border , component cannot resolve its form.
  * [WICKET-2456] - DateTextField cannot work with default converter
 (or javadoc wrong)
  * [WICKET-2457] - Flash/ExternalInterface does not work in IE if
 movie is fetched via Wicket/Ajax
  * [WICKET-2458] - JavascriptUtils.escapeQuotes() misses escaping
 double quotes
  * [WICKET-2461] - AjaxPagingNavigationIncrementLink does not work
 without AjaxPagingNavigator component
  * [WICKET-2463] - Ajax miltipart form submitting ignores
 setDefaultFormProcessing(false)
  * [WICKET-2466] - javadoc the CryptedUrlWebRequestCodingStrategy
 needs to be update/corrected to reflect the usage of session-id for
 encryption and hence URLs which were bookmarkable before will NOT
 remain bookmarkable.
  * [WICKET-2475] - NPE after application hot redeployment
  * [WICKET-2477] - AjaxEditableChoiceLabel does not detach choices model
  * [WICKET-2478] - TabbedPanel rendering bug
  * [WICKET-2485] - IComponentResolvers are not supported inside
 wicket:enclosure
  * [WICKET-2488] - QuickFix proposal
 WicketTesterHelper.assertEquals(final Collection? expects, final
 Collection? actuals) should compare list sizes

 ** Improvement
  * [WICKET-626] - profile Wicket for 1.4.0
  * [WICKET-2435] - TabbedPanel extract factory method for tabs-container
  * [WICKET-2439] - Improve MixedParamUrlCodingStrategy, introduce Hybrid
  * [WICKET-2444] - Internal Spring beans should be ignored
  * [WICKET-2445] - FormInput.java needs the validators updated.
  * [WICKET-2449] - Fix javadoc biggest mistakes - mainly @Deprecated tags
  * [WICKET-2454] - IE8: be more verbose if ajax refresh fails
  * [WICKET-2469] - Allow using a different FileItemFactory by
 extracting a method in MultipartServletWebRequest class
  * [WICKET-2492] - Application_pt_BR.properties path

 ** New Feature
  * [WICKET-2395] - add MixedParamHybridUrlCodingStrategy
  * [WICKET-2483] - Access to WizardModel.conditions

 ** Wish
  * [WICKET-2120] - widen visibiliy of GuiceProxyTargetLocator  and
 findBindingAnnotation
  * [WICKET-2462] - Would it possible add chinese resource label for
 WizardButton eg. CancelButton, NextButton and PreviousButton etc.
  * [WICKET-2489] - need to know if a component has been added to
 the AjaxRequestTarget

 We thank you for your patience and support.

 The Wicket Team

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







-- 
Many thanks!

Haulyn Microproduction

You can access me with the following ways:
Location: Shandong Jinan Shumagang 6H-8, 25
Mobile: +086-15864011231
email: saharab...@gmail.com, hmp.hau...@foxmail.com
website: http://haulynjason.net
gtalk: saharab...@gmail.com
skype: saharabear
QQ: 378606292
persional Twitter: http://twitter.com/saharabear
persional Linkedin: http://www.linkedin.com/in/haulyn
Haulyn Microproduction Twitter: http://twitter.com/haulynmp


Haulyn Jason


how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread Paul Huang
Suppose I write my own wicket component called XYZ that have the following
markup

wicket:panel
div wicket:id=id_xxx

/div
/wicket:panel

How can I inject some js code into this markup so when it's rendered in a
page, I got something like

wicket:panel
div wicket:id=id_xxx
 script type=text/javascript
 var data=[abc, efg];
 document.write(data[0]);
/script
.
div
wicket:panel

You may ask why I dont simply keep the js code into the component markup
XYZ.html, this is because the value of data variable will be provided by
the user and is not fixed.


Re: AjaxRequestTarget javascript execution order

2009-10-10 Thread McIlwee, Craig
Have you tried prependJavascript(String) instead of append?  Javadoc:

Adds javascript that will be evaluated on the client side before components 
are replaced

Sounds like what you're looking for if I'm understanding your question 
correctly.

Craig
  _  

From: Daniele Dellafiore [mailto:ilde...@gmail.com]
To: users@wicket.apache.org
Sent: Sat, 10 Oct 2009 07:51:27 -0400
Subject: AjaxRequestTarget javascript execution order

Hi.
  
  In my application I want to execute some javascript on a component
  that is going to be removed when a parent component is refreshed
  causing him to be removed from DOM.
  
  What happens is that DOM is refreshed before the script added vua
  target.appendJavascript(mySCript) is executed. So myScript does not
  find the old component.
  
  I have looked the AjaxRequestTarget.respond(final RequestCycle
  requestCycle) and I have seen that the onDomreadyJavascript is added
  before the appendJavascript. Is this relevant? I guess that the js
  code that refresh DOM is executed even before the onDomReadyJs, right?
  
  So how may I execute some custom javascript on a AjaxRequestTarget
  that also add a component to be refreshed via ART.addComponent() so
  that my custom js is executed before the DOM is modified?
  
  -- 
  Daniele Dellafiore
  http://blog.ildella.net
  http://twitter.com/ildella
  
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
  


Re: AjaxRequestTarget javascript execution order

2009-10-10 Thread Daniele Dellafiore
you are my favourite person in the world today :)

On Sat, Oct 10, 2009 at 3:07 PM, McIlwee, Craig
craig.mcil...@openroadsconsulting.com wrote:
 Have you tried prependJavascript(String) instead of append?  Javadoc:

 Adds javascript that will be evaluated on the client side before components 
 are replaced

 Sounds like what you're looking for if I'm understanding your question 
 correctly.

 Craig
  _

 From: Daniele Dellafiore [mailto:ilde...@gmail.com]
 To: users@wicket.apache.org
 Sent: Sat, 10 Oct 2009 07:51:27 -0400
 Subject: AjaxRequestTarget javascript execution order

 Hi.

  In my application I want to execute some javascript on a component
  that is going to be removed when a parent component is refreshed
  causing him to be removed from DOM.

  What happens is that DOM is refreshed before the script added vua
  target.appendJavascript(mySCript) is executed. So myScript does not
  find the old component.

  I have looked the AjaxRequestTarget.respond(final RequestCycle
  requestCycle) and I have seen that the onDomreadyJavascript is added
  before the appendJavascript. Is this relevant? I guess that the js
  code that refresh DOM is executed even before the onDomReadyJs, right?

  So how may I execute some custom javascript on a AjaxRequestTarget
  that also add a component to be refreshed via ART.addComponent() so
  that my custom js is executed before the DOM is modified?

  --
  Daniele Dellafiore
  http://blog.ildella.net
  http://twitter.com/ildella

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





-- 
Daniele Dellafiore
http://blog.ildella.net
http://twitter.com/ildella

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



Re: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread McIlwee, Craig
If your component is a MarkupContainer you can override 
getAssociatedMarkupStream(boolean) and build the markup on the fly.  So maybe 
still have the HTML file that you read in as a template with some place holder 
string and in the override you replace the place holder with stuff you want to 
be assigned to the data variable.  Then use a StringResourceStream to create a 
MarkupResourceStream, use SimpleMarkupLoader to create a Markup instance from 
the MarkupResourceStream, and finally create a MarkupStream with your Markup 
instance.

One thing to note is that if your markup container has child components that 
will be updated via AJAX AND you don't have an HTML file (you build the entire 
string on the fly) then you may also have to override hasAssociatedMarkupStream 
and always return true else the component being updated won't be able to locate 
its parent.

Craig
  _  

From: Paul Huang [mailto:paulhuan...@gmail.com]
To: users@wicket.apache.org
Sent: Sat, 10 Oct 2009 08:34:15 -0400
Subject: how to inject arbitrary javascript code to a component markup?

Suppose I write my own wicket component called XYZ that have the following
  markup
  
  wicket:panel
  div wicket:id=id_xxx
  
  /div
  /wicket:panel
  
  How can I inject some js code into this markup so when it's rendered in a
  page, I got something like
  
  wicket:panel
  div wicket:id=id_xxx
   script type=text/javascript
   var data=[abc, efg];
   document.write(data[0]);
  /script
  .
  div
  wicket:panel
  
  You may ask why I dont simply keep the js code into the component markup
  XYZ.html, this is because the value of data variable will be provided by
  the user and is not fixed.


Re: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread PaulH98



McIlwee, Craig wrote:
 
 If your component is a MarkupContainer you can override
 getAssociatedMarkupStream(boolean) and build the markup on the fly.  So
 maybe still have the HTML file that you read in as a template with some
 place holder string and in the override you replace the place holder with
 stuff you want to be assigned to the data variable.  Then use a
 StringResourceStream to create a MarkupResourceStream, use
 SimpleMarkupLoader to create a Markup instance from the
 MarkupResourceStream, and finally create a MarkupStream with your Markup
 instance.
 
 One thing to note is that if your markup container has child components
 that will be updated via AJAX AND you don't have an HTML file (you build
 the entire string on the fly) then you may also have to override
 hasAssociatedMarkupStream and always return true else the component being
 updated won't be able to locate its parent.
 
 Craig  
 


Here is the java code of my component CategorySelectPanel that extends
Panel



 public class CategorySelectPanel extends Panel{
   private static final long serialVersionUID = 1L;
   public CategorySelectPanel(String wicketId){
   super(wicketId);
   WebMarkupContainer cat0=new WebMarkupContainer(cat0);
   cat0.setOutputMarkupId(true);
   add(cat0);
   MarkupStream ms=getAssociatedMarkupStream(true); 
   System.out.println(ms.toString());
   
   }
 }
 

and here is the associated markup file CategorySelectPanel.html


 wicket:panel
   div wicket:id=cat0 class=cat0/div
 /wicket:panel
 
 


Now I have  a simple test


 
 public class TestPage extends WebPage{
   public TestPage(){
   CategorySelectPanel a= new CategorySelectPanel(csp);
   add(a);
   }
 }
 
with the the following page html 


 
 html
 head
 meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
 titleInsert title here/title
 /head
 body
 
 /body
 /html
 
 

when I run the test, I got the following exception 



 WicketMessage: Can't instantiate page using constructor public
 com.tree.TestPage()
 
 Root cause:
 
 java.lang.IllegalStateException: No Page found for component
 [MarkupContainer [Component id = csp]]
 at org.apache.wicket.Component.getPage(Component.java:1763)
 at
 org.apache.wicket.markup.html.WebMarkupContainer.getMarkupType(WebMarkupContainer.java:60)
 at
 org.apache.wicket.markup.DefaultMarkupCacheKeyProvider.getCacheKey(DefaultMarkupCacheKeyProvider.java:57)
 at org.apache.wicket.markup.MarkupCache.getMarkup(MarkupCache.java:291)
 at
 org.apache.wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:216)
 at
 org.apache.wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:351)
 at com.tree.CategorySelectPanel.init(CategorySelectPanel.java:37)
 at com.tree.TestPage.init(TestPage.java:7)
 
 

Basically, MarkupStream ms=getAssociatedMarkupStream(true)  caused this
exception. Can anyone shed some light on this? I am trying to Carig's
suggestion to get the MarkupStream and alter it with my stuff.


-- 
View this message in context: 
http://www.nabble.com/how-to-inject-arbitrary-javascript-code-to-a-component-markup--tp25833726p25834380.html
Sent from the Wicket - User 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 inject arbitrary javascript code to a component markup?

2009-10-10 Thread Fatih Mehmet UCAR
Add a div to your page like below:

html
head
meta http-equiv=Content-Type content=text/html; 
charset=ISO-8859-1 titleInsert title here/title /head 
body

div wicket:id=csp/div

/body
/html

-Original Message-
From: PaulH98 [mailto:paulhuan...@gmail.com] 
Sent: 10 October 2009 14:58
To: users@wicket.apache.org
Subject: Re: how to inject arbitrary javascript code to a component markup?




McIlwee, Craig wrote:
 
 If your component is a MarkupContainer you can override
 getAssociatedMarkupStream(boolean) and build the markup on the fly.  So
 maybe still have the HTML file that you read in as a template with some
 place holder string and in the override you replace the place holder with
 stuff you want to be assigned to the data variable.  Then use a
 StringResourceStream to create a MarkupResourceStream, use
 SimpleMarkupLoader to create a Markup instance from the
 MarkupResourceStream, and finally create a MarkupStream with your Markup
 instance.
 
 One thing to note is that if your markup container has child components
 that will be updated via AJAX AND you don't have an HTML file (you build
 the entire string on the fly) then you may also have to override
 hasAssociatedMarkupStream and always return true else the component being
 updated won't be able to locate its parent.
 
 Craig  
 


Here is the java code of my component CategorySelectPanel that extends
Panel



 public class CategorySelectPanel extends Panel{
   private static final long serialVersionUID = 1L;
   public CategorySelectPanel(String wicketId){
   super(wicketId);
   WebMarkupContainer cat0=new WebMarkupContainer(cat0);
   cat0.setOutputMarkupId(true);
   add(cat0);
   MarkupStream ms=getAssociatedMarkupStream(true); 
   System.out.println(ms.toString());
   
   }
 }
 

and here is the associated markup file CategorySelectPanel.html


 wicket:panel
   div wicket:id=cat0 class=cat0/div
 /wicket:panel
 
 


Now I have  a simple test


 
 public class TestPage extends WebPage{
   public TestPage(){
   CategorySelectPanel a= new CategorySelectPanel(csp);
   add(a);
   }
 }
 
with the the following page html 


 
 html
 head
 meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1
 titleInsert title here/title
 /head
 body
 
 /body
 /html
 
 

when I run the test, I got the following exception 



 WicketMessage: Can't instantiate page using constructor public
 com.tree.TestPage()
 
 Root cause:
 
 java.lang.IllegalStateException: No Page found for component
 [MarkupContainer [Component id = csp]]
 at org.apache.wicket.Component.getPage(Component.java:1763)
 at

org.apache.wicket.markup.html.WebMarkupContainer.getMarkupType(WebMarkupCont
ainer.java:60)
 at

org.apache.wicket.markup.DefaultMarkupCacheKeyProvider.getCacheKey(DefaultMa
rkupCacheKeyProvider.java:57)
 at org.apache.wicket.markup.MarkupCache.getMarkup(MarkupCache.java:291)
 at
 org.apache.wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:216)
 at

org.apache.wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.
java:351)
 at com.tree.CategorySelectPanel.init(CategorySelectPanel.java:37)
 at com.tree.TestPage.init(TestPage.java:7)
 
 

Basically, MarkupStream ms=getAssociatedMarkupStream(true)  caused this
exception. Can anyone shed some light on this? I am trying to Carig's
suggestion to get the MarkupStream and alter it with my stuff.


-- 
View this message in context:
http://www.nabble.com/how-to-inject-arbitrary-javascript-code-to-a-component
-markup--tp25833726p25834380.html
Sent from the Wicket - User 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: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread PaulH98



Fatih Mehmet UCAR wrote:
 
 Add a div to your page like below:
 
 html
 head
 meta http-equiv=Content-Type content=text/html; 
 charset=ISO-8859-1 titleInsert title here/title /head 
 body
 
   div wicket:id=csp/div
 
 /body
 /html
 
 

Thanks Fatih, Indeed, I had div wicket:id=csp/div in my test page,
but somehow deleted it when posting my previous message. The same problem
persists. 

-- 
View this message in context: 
http://www.nabble.com/how-to-inject-arbitrary-javascript-code-to-a-component-markup--tp25833726p25834544.html
Sent from the Wicket - User 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 inject arbitrary javascript code to a component markup?

2009-10-10 Thread Igor Vaynberg
can you not just use a label whose model is the script.../script string?

-igor

On Sat, Oct 10, 2009 at 5:34 AM, Paul Huang paulhuan...@gmail.com wrote:
 Suppose I write my own wicket component called XYZ that have the following
 markup

 wicket:panel
 div wicket:id=id_xxx
 
 /div
 /wicket:panel

 How can I inject some js code into this markup so when it's rendered in a
 page, I got something like

 wicket:panel
 div wicket:id=id_xxx
  script type=text/javascript
     var data=[abc, efg];
     document.write(data[0]);
 /script
 .
 div
 wicket:panel

 You may ask why I dont simply keep the js code into the component markup
 XYZ.html, this is because the value of data variable will be provided by
 the user and is not fixed.


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



Re: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Ceki Gulcu



Eelco Hillenius wrote:

I've looked at it briefly. The main thing you need to keep in mind is
that it unfortunately is a limitation of Wicket that you can't have
references in Components that aren't serializable (unless you don't
care about back button support and turn of the second level session
cache, OR you plug in your own serialization support that doesn't need
classes to be serializable).



Thank you for your response. It is much appreciated.

As I understand it, the back button problem is defined as the
undesired triggering of a transaction subsequent to the user going
back and resubmitting. For example, let page C be a purchase
confirmation page and T be the thank you for your purchase page
after the user confirms a certain purchase. The user confirms a
purchase on C and the application sends T in response. If the user
clicks on the back button and resubmits C, then the application should
prevent a presumably unwanted re-purchase. Invalidating the cart when
T is sent to the user is sufficient to solve this particular
back-button problem.

Again, as I understand it, instead of preserving state, the back-button
problem is addressed by invalidating state. Surely, wicket is
addressing a subtler back-button problem.


In this case though, you don't really need those members, right? All
the members are used in methods that are called during construction of
the panel, so why not just pass them through those methods (or if you
don't like that, make the members transient)?


Since admittedly I don't actually understand the back-button problem, I
don't see the consequences of eliminating references to unserializable
members in my wicket components. I guess I'll have to experiment.

Alternatively, in the case of this particular problem, I could
construct a parallel serializable class hierarchy. While in the
general case such an approach could be qualified as inelegant or even
dumb, in this particular case it might the cheaper and the more
elegant solution.

Is there a wicket-example illustrating the back-button problem solved
by wicket? I looked at http://wicketstuff.org/wicket14/stateless/ but
its point was lost on me.



Eelco

On Fri, Oct 9, 2009 at 2:16 PM, Ceki Gulcu c...@qos.ch wrote:


Eelco Hillenius wrote:

Hi,

It looks like GenericBaseModel has a reference to a JUnit Description?
Maybe you can paste your GenericBaseModel class here?

Fortunately, my application is open source. You can find its source code at

 http://github.com/ceki/mistletoe

If you look at the DescriptionPanel class [1] you'll see that it essentially
presents a junit.Description and a junit.Failure instance both of which are
non-serializable.

[1] http://tinyurl.com/yha75x8



If that's something you'll have a runtime you shouldn't ignore it if
you want to support history (the backbutton). If it's just during
testing, you can ignore it if you like.

My application is a testing platform so I can't ignore junit nor testing.
:-)


--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

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



Re: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread Anton Veretennikov
For example I use this markup:

script wicket:id=focusScript/script

and associate it with simple class:

public class FocusScript extends Label {

  public FocusScript(String id, String focusFieldMarkupId, boolean selectAll) {
super(id, getFocusScript(focusFieldMarkupId, selectAll));
setEscapeModelStrings(false);
  }

  @Override
  protected void onComponentTag(ComponentTag tag) {
tag.put(language, javascript);
tag.put(type, text/javascript);
super.onComponentTag(tag);
  }

  @Override
  protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
super.onComponentTagBody(markupStream, openTag);
checkComponentTag(openTag, script);
  }

  public static String getFocusScript(String focusFieldMarkupId,
boolean selectAll) {
return document.getElementById(' + focusFieldMarkupId + ').focus(); +
(selectAll?(document.getElementById(' +
focusFieldMarkupId + ').select()):);
  }


}


On Sat, Oct 10, 2009 at 11:11 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 can you not just use a label whose model is the script.../script string?

 -igor

 On Sat, Oct 10, 2009 at 5:34 AM, Paul Huang paulhuan...@gmail.com wrote:
 Suppose I write my own wicket component called XYZ that have the following
 markup

 wicket:panel
 div wicket:id=id_xxx
 
 /div
 /wicket:panel

 How can I inject some js code into this markup so when it's rendered in a
 page, I got something like

 wicket:panel
 div wicket:id=id_xxx
  script type=text/javascript
     var data=[abc, efg];
     document.write(data[0]);
 /script
 .
 div
 wicket:panel

 You may ask why I dont simply keep the js code into the component markup
 XYZ.html, this is because the value of data variable will be provided by
 the user and is not fixed.


 -
 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: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Ceki Gulcu



Igor Vaynberg wrote:

On Fri, Oct 9, 2009 at 1:41 PM, Ceki Gulcu c...@qos.ch wrote:

Anyway, my application handles a complex tree-like structure, with
almost all of the contents non-serializable and outside my control. I
don't think I can use a Loadable Detachable Model, because loading the
tree may take several minutes.


you would use an LDM per node - the LDM should load the object
represented by that node only, not the entire tree.

does that make sense?


LDM makes sense if you can detach data and then re-attach at a later
time. In my case, I can't re-attach data without potentially paying a
very severe penalty. (There is no datasource which can be queried for
my data, as my data is runtime data. I'd need to re-run tests to
re-acquire, which is pretty much nonsensical.)


-igor


--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

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



Re: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Igor Vaynberg
what is the lifecycle of this data? when do you no longer need to store it?

if this is runtime data you can create a runtime store for it, even a
simple map can do. this map can live in servlet context, spring
context, as a field of your wicket application, etc. the user pages
can then retrieve this data without actually having to have a hard
reference to it. the only trick is knowing when to remove this data
from memory.

-igor

On Sat, Oct 10, 2009 at 8:39 AM, Ceki Gulcu c...@qos.ch wrote:


 Igor Vaynberg wrote:

 On Fri, Oct 9, 2009 at 1:41 PM, Ceki Gulcu c...@qos.ch wrote:

 Anyway, my application handles a complex tree-like structure, with
 almost all of the contents non-serializable and outside my control. I
 don't think I can use a Loadable Detachable Model, because loading the
 tree may take several minutes.

 you would use an LDM per node - the LDM should load the object
 represented by that node only, not the entire tree.

 does that make sense?

 LDM makes sense if you can detach data and then re-attach at a later
 time. In my case, I can't re-attach data without potentially paying a
 very severe penalty. (There is no datasource which can be queried for
 my data, as my data is runtime data. I'd need to re-run tests to
 re-acquire, which is pretty much nonsensical.)

 -igor

 --
 Ceki Gülcü
 Logback: The reliable, generic, fast and flexible logging framework for
 Java.
 http://logback.qos.ch

 -
 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: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Igor Vaynberg
in other words, if you were building this app using jsps or servlets
how would you carry over this data structure between requests?

-igor

On Sat, Oct 10, 2009 at 9:09 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 what is the lifecycle of this data? when do you no longer need to store it?

 if this is runtime data you can create a runtime store for it, even a
 simple map can do. this map can live in servlet context, spring
 context, as a field of your wicket application, etc. the user pages
 can then retrieve this data without actually having to have a hard
 reference to it. the only trick is knowing when to remove this data
 from memory.

 -igor

 On Sat, Oct 10, 2009 at 8:39 AM, Ceki Gulcu c...@qos.ch wrote:


 Igor Vaynberg wrote:

 On Fri, Oct 9, 2009 at 1:41 PM, Ceki Gulcu c...@qos.ch wrote:

 Anyway, my application handles a complex tree-like structure, with
 almost all of the contents non-serializable and outside my control. I
 don't think I can use a Loadable Detachable Model, because loading the
 tree may take several minutes.

 you would use an LDM per node - the LDM should load the object
 represented by that node only, not the entire tree.

 does that make sense?

 LDM makes sense if you can detach data and then re-attach at a later
 time. In my case, I can't re-attach data without potentially paying a
 very severe penalty. (There is no datasource which can be queried for
 my data, as my data is runtime data. I'd need to re-run tests to
 re-acquire, which is pretty much nonsensical.)

 -igor

 --
 Ceki Gülcü
 Logback: The reliable, generic, fast and flexible logging framework for
 Java.
 http://logback.qos.ch

 -
 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: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Ceki Gulcu



Igor Vaynberg wrote:

in other words, if you were building this app using jsps or servlets
how would you carry over this data structure between requests?


No, I actually would not carry the data between requests. When the
page is requested, I would run my test suite to compute the
results. Serving the test results from a previous test run is useless
and is likely to be misleading..

Following Eelco's suggestion, I've set all the fields in my panel
(DescriptionPanel) to transient. However, in one case the panel
creates a ListView which references non-serializable data items. Thus I
started creating a parallel and serializable data class hierarchy for
presenting my results, which I am actually quite happy about. However,
I also wish I knew a simpler solution if the same question arose in a
different context where duplicating the class hierarchy would be
inappropriate.


-igor

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

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



Re: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread McIlwee, Craig
Didn't think of that approach, looks good.  But to clear up my previous 
suggestion since I guess I wasn't clear enough and its useful in other 
situations also, you need to _override_ getAssociatedMarkupStream(boolean), not 
just call it.

public static final String JAVASCRIPT_PLACEHOLDER = %JS_HERE%;
public MarkupStream getAssociatedMarkupStream(boolean throwEx) {
  String jsToInsert = ... // create your java script
  String html = ... // read HTML file via getClass().getResource
  html = html.replace(JAVASCRIPT_PLACEHOLDER, jsToInsert);
  IResourceStream srs = new StringResourceStream(html);
  MarkupResourceStream mrs = new MarkupResourceStream(srs);
  Markup markup = new SimpleMarkupLoader().loadMarkup(this, mrs, null, true);
  return new MarkupStream(markup);
}

and your panel

wicket:panel
!-- some markup here --
%JS_HERE%
!-- more markup --
/wicket:panel

Craig
  _  

From: Anton Veretennikov [mailto:anton.veretenni...@gmail.com]
To: users@wicket.apache.org
Sent: Sat, 10 Oct 2009 11:24:12 -0400
Subject: Re: how to inject arbitrary javascript code to a component markup?

For example I use this markup:
  
  script wicket:id=focusScript/script
  
  and associate it with simple class:
  
  public class FocusScript extends Label {
  
public FocusScript(String id, String focusFieldMarkupId, boolean selectAll) 
{
  super(id, getFocusScript(focusFieldMarkupId, selectAll));
  setEscapeModelStrings(false);
}
  
@Override
protected void onComponentTag(ComponentTag tag) {
  tag.put(language, javascript);
  tag.put(type, text/javascript);
  super.onComponentTag(tag);
}
  
@Override
protected void onComponentTagBody(MarkupStream markupStream,
  ComponentTag openTag) {
  super.onComponentTagBody(markupStream, openTag);
  checkComponentTag(openTag, script);
}
  
public static String getFocusScript(String focusFieldMarkupId,
  boolean selectAll) {
  return document.getElementById(' + focusFieldMarkupId + ').focus(); +
  (selectAll?(document.getElementById(' +
  focusFieldMarkupId + ').select()):);
}
  
  
  }
  
  
  On Sat, Oct 10, 2009 at 11:11 PM, Igor Vaynberg igor.vaynb...@gmail.com 
wrote:
   can you not just use a label whose model is the script.../script 
string?
  
   -igor
  
   On Sat, Oct 10, 2009 at 5:34 AM, Paul Huang paulhuan...@gmail.com wrote:
   Suppose I write my own wicket component called XYZ that have the following
   markup
  
   wicket:panel
   div wicket:id=id_xxx
   
   /div
   /wicket:panel
  
   How can I inject some js code into this markup so when it's rendered in a
   page, I got something like
  
   wicket:panel
   div wicket:id=id_xxx
script type=text/javascript
   var data=[abc, efg];
   document.write(data[0]);
   /script
   .
   div
   wicket:panel
  
   You may ask why I dont simply keep the js code into the component markup
   XYZ.html, this is because the value of data variable will be provided 
by
   the user and is not fixed.
  
  
   -
   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: SerializableChecker$WicketNotSerializableException:

2009-10-10 Thread Igor Vaynberg
if you do not need to hold on to the data structure between requests
then there is no need to keep any references to it in the components
themselves. pass it into the constructor, create whatever components
you need to represent it in the ui and throw it away. you may have to
create wrappers around parts of it for some components, i suppose, but
you should be able to getaway without keeping a reference to it in
most cases.

a simplified example may be

class mypanel extends panel {
  public mypanel (string id, nonserializable data) {
 add(new label(name, data.getname()));
 add(new label(author, data.getauthor()));

 // instead of using a listview for repeaters use repeatingview
which lets you construct a repeater without a backing model
 repeatingview rows=new repeatingview();
 add(rows);
 for (change:data.getchanges()) {
   webmarkupcontainer row=new webmarkupcontainer(rows.newchildid());
   rows.add(row);
   row.add(new label(author, change.getauthor());
   row.add(new changesetpanel(changeset, change));
 }
  }
}


-igor

On Sat, Oct 10, 2009 at 9:35 AM, Ceki Gulcu c...@qos.ch wrote:


 Igor Vaynberg wrote:

 in other words, if you were building this app using jsps or servlets
 how would you carry over this data structure between requests?

 No, I actually would not carry the data between requests. When the
 page is requested, I would run my test suite to compute the
 results. Serving the test results from a previous test run is useless
 and is likely to be misleading..

 Following Eelco's suggestion, I've set all the fields in my panel
 (DescriptionPanel) to transient. However, in one case the panel
 creates a ListView which references non-serializable data items. Thus I
 started creating a parallel and serializable data class hierarchy for
 presenting my results, which I am actually quite happy about. However,
 I also wish I knew a simpler solution if the same question arose in a
 different context where duplicating the class hierarchy would be
 inappropriate.

 -igor

 --
 Ceki Gülcü
 Logback: The reliable, generic, fast and flexible logging framework for
 Java.
 http://logback.qos.ch

 -
 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: how to inject arbitrary javascript code to a component markup?

2009-10-10 Thread PaulH98



Anton Veretennikov wrote:
 
 For example I use this markup:
 
 script wicket:id=focusScript/script
 
 and associate it with simple class:
 
 public class FocusScript extends Label {
 
   public FocusScript(String id, String focusFieldMarkupId, boolean
 selectAll) {
 super(id, getFocusScript(focusFieldMarkupId, selectAll));
 setEscapeModelStrings(false);
   }
 
   @Override
   protected void onComponentTag(ComponentTag tag) {
 tag.put(language, javascript);
 tag.put(type, text/javascript);
 super.onComponentTag(tag);
   }
 
   @Override
   protected void onComponentTagBody(MarkupStream markupStream,
 ComponentTag openTag) {
 super.onComponentTagBody(markupStream, openTag);
 checkComponentTag(openTag, script);
   }
 
   public static String getFocusScript(String focusFieldMarkupId,
 boolean selectAll) {
 return document.getElementById(' + focusFieldMarkupId +
 ').focus(); +
 (selectAll?(document.getElementById(' +
 focusFieldMarkupId + ').select()):);
   }
 
 }
 
 

Thanks Igor and Anton. That approach works. One thing to remember is to call
setEscapeModelStrings(false) to insert string script /script as
it is, as Anton pointed out.



-- 
View this message in context: 
http://www.nabble.com/how-to-inject-arbitrary-javascript-code-to-a-component-markup--tp25833726p25837324.html
Sent from the Wicket - User 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 inject arbitrary javascript code to a component markup?

2009-10-10 Thread PaulH98



McIlwee, Craig wrote:
 
 Didn't think of that approach, looks good.  But to clear up my previous
 suggestion since I guess I wasn't clear enough and its useful in other
 situations also, you need to _override_
 getAssociatedMarkupStream(boolean), not just call it.
 
 public static final String JAVASCRIPT_PLACEHOLDER = %JS_HERE%;
 public MarkupStream getAssociatedMarkupStream(boolean throwEx) {
   String jsToInsert = ... // create your java script
   String html = ... // read HTML file via getClass().getResource
   html = html.replace(JAVASCRIPT_PLACEHOLDER, jsToInsert);
   IResourceStream srs = new StringResourceStream(html);
   MarkupResourceStream mrs = new MarkupResourceStream(srs);
   Markup markup = new SimpleMarkupLoader().loadMarkup(this, mrs, null,
 true);
   return new MarkupStream(markup);
 }
 
 and your panel
 
 wicket:panel
 !-- some markup here --
 %JS_HERE%
 !-- more markup --
 /wicket:panel
 Craig
 

Carig- Just tried your approach, it works as well. Thanks for your help.
Here is the complete code, just in case someone else may need it.



 @Override
   public MarkupStream getAssociatedMarkupStream(boolean throwEx) {
 String jsToInsert =my js code; // create your java script
 InputStream
 htmlStream=this.getClass().getResourceAsStream(YOUR_MARKUP_TEMPLATE.html);
 String html=convertStreamToString(htmlStream);
 html = html.replace(JAVASCRIPT_PLACEHOLDER, jsToInsert);
 IResourceStream srs = new StringResourceStream(html);
 MarkupResourceStream mrs = new MarkupResourceStream(srs);
 Markup markup = null;
   try {
   markup = new 
 SimpleMarkupLoader().loadMarkup(this, mrs, null, true);
   } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   } catch (ResourceStreamNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   }
 return new MarkupStream(markup);
   } 
   
   public String convertStreamToString(InputStream is) {
   /*
* To convert the InputStream to String we use the
 BufferedReader.readLine()
* method. We iterate until the BufferedReader return 
 null which
 means
* there's no more data to read. Each line will 
 appended to a
 StringBuilder
* and returned as String.
*/
   BufferedReader reader = new BufferedReader(new
 InputStreamReader(is));
   StringBuilder sb = new StringBuilder();
   
   String line = null;
   try {
   while ((line = reader.readLine()) != null) {
   sb.append(line + \n);
   }
   } catch (IOException e) {
   e.printStackTrace();
   } finally {
   try {
   is.close();
   } catch (IOException e) {
   e.printStackTrace();
   }
   }

   return sb.toString();
   }
 

-- 
View this message in context: 
http://www.nabble.com/how-to-inject-arbitrary-javascript-code-to-a-component-markup--tp25833726p25837543.html
Sent from the Wicket - User 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: Wicket 1.4.2 Released!

2009-10-10 Thread Luca Provenzani
Thank You very much,
I'll update our project early.

Luca


2009/10/10 Igor Vaynberg igor.vaynb...@gmail.com

 The Apache Wicket project is proud to announce the second maintenance
 release of Apache Wicket 1.4.

 Download Apache Wicket 1.4
 ---

 You can download the release here:
 http://www.apache.org/dyn/closer.cgi/wicket/1.4.2

 Or use this in your Maven pom's to upgrade to the new version:

 dependency
  groupIdorg.apache.wicket/groupId
  artifactIdwicket/artifactId
  version1.4.2/version
 /dependency

 Release Notes - Wicket - Version 1.4.2

 ** Bug
  * [WICKET-2393] - Passwords should not be trimmed
  * [WICKET-2430] - Malformed \u encoding in
 MultipleUploadField_sl.properties
  * [WICKET-2433] - Ajax support for multipart forms broken in a nested form
  * [WICKET-2434] - RequestCycle urlFor ignores existing parameters
 when appending provided params
  * [WICKET-2436] - invalid DataTable markup breaks table layout
  * [WICKET-2438] - AjaxEventBehavior not working on feedback
 message components
  * [WICKET-2453] - Form.findForm(Component c) bug. When form is
 part of Border and form component like TextField is inside another
 Border , component cannot resolve its form.
  * [WICKET-2456] - DateTextField cannot work with default converter
 (or javadoc wrong)
  * [WICKET-2457] - Flash/ExternalInterface does not work in IE if
 movie is fetched via Wicket/Ajax
  * [WICKET-2458] - JavascriptUtils.escapeQuotes() misses escaping
 double quotes
  * [WICKET-2461] - AjaxPagingNavigationIncrementLink does not work
 without AjaxPagingNavigator component
  * [WICKET-2463] - Ajax miltipart form submitting ignores
 setDefaultFormProcessing(false)
  * [WICKET-2466] - javadoc the CryptedUrlWebRequestCodingStrategy
 needs to be update/corrected to reflect the usage of session-id for
 encryption and hence URLs which were bookmarkable before will NOT
 remain bookmarkable.
  * [WICKET-2475] - NPE after application hot redeployment
  * [WICKET-2477] - AjaxEditableChoiceLabel does not detach choices model
  * [WICKET-2478] - TabbedPanel rendering bug
  * [WICKET-2485] - IComponentResolvers are not supported inside
 wicket:enclosure
  * [WICKET-2488] - QuickFix proposal
 WicketTesterHelper.assertEquals(final Collection? expects, final
 Collection? actuals) should compare list sizes

 ** Improvement
  * [WICKET-626] - profile Wicket for 1.4.0
  * [WICKET-2435] - TabbedPanel extract factory method for tabs-container
  * [WICKET-2439] - Improve MixedParamUrlCodingStrategy, introduce Hybrid
  * [WICKET-2444] - Internal Spring beans should be ignored
  * [WICKET-2445] - FormInput.java needs the validators updated.
  * [WICKET-2449] - Fix javadoc biggest mistakes - mainly @Deprecated tags
  * [WICKET-2454] - IE8: be more verbose if ajax refresh fails
  * [WICKET-2469] - Allow using a different FileItemFactory by
 extracting a method in MultipartServletWebRequest class
  * [WICKET-2492] - Application_pt_BR.properties path

 ** New Feature
  * [WICKET-2395] - add MixedParamHybridUrlCodingStrategy
  * [WICKET-2483] - Access to WizardModel.conditions

 ** Wish
  * [WICKET-2120] - widen visibiliy of GuiceProxyTargetLocator  and
 findBindingAnnotation
  * [WICKET-2462] - Would it possible add chinese resource label for
 WizardButton eg. CancelButton, NextButton and PreviousButton etc.
  * [WICKET-2489] - need to know if a component has been added to
 the AjaxRequestTarget

 We thank you for your patience and support.

 The Wicket Team

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




Re: DropDownChoice and onSelectionChanged error.

2009-10-10 Thread Altuğ B . Altıntaş
Thanks Fatih. It is my fault, i solved the problem.
Altug.

2009/10/9 Fatih Mehmet Ucar fmu...@gmail.com

 If you use the below constrcutor, it should solve your problem.

 DropDownChoice(java.lang.String id, IModel model, IModel choices,
 IChoiceRenderer renderer)



 2009/10/9 Altuğ B. Altıntaş alt...@gmail.com:
  Hi;
  I have a problem with DropDownChoice; The code block is here :
 
  ListFaaliyetfaaliyetListesi = // data comes
 
   final DropDownChoiceFaaliyet faaliyetler =
 new DropDownChoiceFaaliyet(Faaliyetler,
 new Model((Serializable) faaliyetListesi),
  faaliyetlerRenderer) {
 
 @Override
 protected boolean
 wantOnSelectionChangedNotifications()
  {
 return true;
 }
 
 @Override
 protected void onSelectionChanged(Faaliyet
 newSelection)
  {
 super.onSelectionChanged(newSelection);
 PageParameters params = new PageParameters();
 params.add(ay, finalAy + );
 params.add(yil, finalYil + );
 params.add(faaliyetId, newSelection.getId() +
 );
 setResponsePage(ActionPage.class, params);
 
 }
 };
 
 
 add(faaliyetler);
 
 
 
  The error message is :
 
  wicketMessage: Method onSelectionChanged of interface
  org.apache.wicket.markup.html.form.IOnChangeListener targeted at
  component [MarkupContainer [Component id = Faaliyetler]] threw an
  exception
 
  Root cause:
 
  java.lang.IllegalStateException: Attempt to set model object on null
  model of component: Faaliyetler
  at
 org.apache.wicket.Component.setDefaultModelObject(Component.java:3038)
  at
 org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168)
  at
 org.apache.wicket.markup.html.form.DropDownChoice.onSelectionChanged(DropDownChoice.java:158)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at
 org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
  at
 org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
  at
 org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.j
 
  --
 
  Any suggestions ?
 
  Altuğ.
 

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




-- 
Altuğ.