By the way what you want to do (adding a js reference to the page isnt
needed at all, just do that in the render head of the
component/behavior itself) wicket transfers it for you to the head of
the page

On 27/06/2009, Johan Compagner <[email protected]> wrote:
> You cant do that in the bind because the bind is called when you add
> the behavior to the component and that is on construction time so the
> component itself isnt added to its parent, or the parent/panel isnt
> added to its parent (you are in the constructor of a panel)
>
> So the hierarchy isnt complete yet
>
> The things you want to do should be done in renderHead() or something like
> that
>
> On 27/06/2009, Azzeddine Daddah <[email protected]> wrote:
>> Hi everybody,
>>
>> I want to create a text blur effect behavior so that when the text
>> field gets focussed, the value will be empty and when blurred the
>> value will be set to the default value.
>> I use the Wickext library which integrates jQuery in Wicket. The
>> problem is that the component's page in the bind() method always
>> returns null and I get this exception message:
>> java.lang.IllegalStateException: No Page found for component
>> [MarkupContainer [Component id = test]].
>> Below my code:
>>
>> BlurFieldBehavior.java
>> ================================
>> public class BlurFieldBehavior extends AbstractBehavior {
>>      private static final String BLUR_FIELD_SCRIPT = "res/blurField.js";
>>
>>      private static final ResourceReference PLUGINS_RESOURCE = new
>> JavascriptResourceReference(BlurFieldBehavior.class,
>> BLUR_FIELD_SCRIPT);
>>
>>      /**
>>       * The behavior is attached to this component.
>>       */
>>      private Component component;
>>
>>      public BlurFieldBehavior() {
>>      }
>>
>>      @Override
>>      public void bind(final Component component) {
>>              super.bind(component);
>>              this.component = component;
>>              Page componentPage = component.getPage();
>>              componentPage.add(new HeaderContributor(new
>> CoreJavaScriptHeaderContributor()));
>>              componentPage.add(new HeaderContributor(new 
>> IHeaderContributor() {
>>                      public void renderHead(IHeaderResponse response) {
>>                              
>> response.renderJavascriptReference(PLUGINS_RESOURCE);
>>                      }
>>              }));
>>      }
>>
>>      @Override
>>      public void renderHead(IHeaderResponse response) {
>>              JsQuery query = new JsQuery(component);
>>              query.$().chain("blurInput");
>>              query.renderHead(response);
>>      }
>> }
>>
>> TestPage.java
>> ================================
>> public class TestPage extends WebPage {
>>      public TestPage() {
>>              add(new TextField<String>("test", new Model<String>("This is a
>> test!!!")).add(new BlurFieldBehavior()));
>>         }
>> }
>>
>> Does someone see what's going wrong with this code?
>>
>> Kind Regards,
>> Hbiloo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to