Re: after render using a behavior vs. override in the component

2008-05-18 Thread Eyal Golan
ok.
But, looking at the Javadoc, this is what I see:
In AbstractBehavior:
/**
 * Called when a component that has this behavior coupled was rendered.
 *
 * @param component
 *the component that has this behavior coupled
 */
public void onRendered(Component component)
{
}

And in Component:
/**
 * Called just after a component is rendered.
 */
protected void onAfterRender()
{
setFlag(FLAG_AFTER_RENDERING, false);
}

It looks to me that according to the API Javadoc the output should be same.
But it isn't.
Am I misunderstanding something or there's a minor bug?

On Sat, May 17, 2008 at 1:45 PM, Johan Compagner [EMAIL PROTECTED]
wrote:

 No the after render of a component is called after the page render to
 clean up stuff.
 Just as onBeforeRender is called before the page is starting to render

 On 5/17/08, Eyal Golan [EMAIL PROTECTED] wrote:
  Isn't this is what I did?
  Anyway, here's an example of what I get.
  First: the Java code:
  public final class TestButtonPage extends WebPage {
  public TestButtonPage() {
  add(new ExtendingButton(extendingButton));
  Button other = new Button(behavioralButton);
  other.add(new MyBehavior());
  add(other);
  }
 
  class ExtendingButton extends Button {
  private static final long serialVersionUID = 1L;
 
  public ExtendingButton(String id) {
  super(id);
  }
 
  @Override
  protected void onAfterRender() {
 
  getResponse().write(spanExtendingButton.onAfterRender()/span);
  super.onAfterRender();
  }
  }
 
  class MyBehavior extends AbstractBehavior {
  private static final long serialVersionUID = 1L;
 
  @Override
  public void onRendered(Component component) {
 
 
 component.getResponse().write(spanAbstractBehavior.onRendered(...)/span);
  }
  }
  }
 
  This is the markup:
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
  html xmlns=http://www.w3.org/1999/xhtml;
  xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
  head
  titleButton Test/title
  /head
  body
  button wicket:id=extendingButtonExtending Button/buttonbr/
  button wicket:id=behavioralButtonBehavioral Button/buttonbr/
  /body
  br /
  spanThis is just before the html closing tag/span
  br /
  /html
 
  And this is the output (taken from view source in my FF browser):
 
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
  html xmlns=http://www.w3.org/1999/xhtml;
xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
  head
  titleButton Test/title
  /head
  body
  button id=extendingButton1 name=extendingButton
  wicket:id=extendingButtonExtending Button/buttonbr/
  button id=behavioralButton2 name=behavioralButton
  wicket:id=behavioralButtonBehavioral
  Button/buttonspanAbstractBehavior.onRendered(...)/spanbr/
  /body
  br /
  spanThis is just before the html closing tag/span
  br /
 
  /html
 
  spanExtendingButton.onAfterRender()/span
 
  As you can see, the behavior put the span tag just after the button,
 but
  the extendingButton put the span tag after the closing tag of the
 html.
 
  Is this the correct behavior?
 
  thanks
 
  On Thu, May 15, 2008 at 4:38 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
  get the components markupid from the component itself.
 
  johan
 
 
  On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED] wrote:
 
   thanks,
   that's exactly what I did.
   I add to my component (button) an AbstarctBehavior, which is an
   IHeaderContributor.
   I even override renderHead:
  @Override
  public void renderHead(IHeaderResponse response) {
  
  
 response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);
  
  
  
 
 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
   //response.renderJavascriptReference(new
   JavascriptResourceReference(
   //EurekifyButtonBehavior.class, resizeScript.js));
  }
  
   The script I am adding to each button comes from a utility class:
  static String getResizeScript(String markupId) {
  StringBuilder strBuilder = new StringBuilder();
  strBuilder.append(script language=\javascript\);
  strBuilder.append(document.getElementById('btnObj_);
  strBuilder.append(markupId);
  strBuilder.append(').style.width = calcBtnSize(');
  strBuilder.append(markupId).append('));
  strBuilder.append(/script);
  return strBuilder.toString();
  }
  
   This is the script that I mentioned in my first question.
  
   Again:
   If I call this script in the Button class, in the onAfterRender()
   method,
   it
   is added to the end of the output HTML.
   If I call this in the behavior, in the 

Re: after render using a behavior vs. override in the component

2008-05-18 Thread Johan Compagner
No no bug just java doc isnt clear enough i guess, but it is not
really wrong.. What is after render? Both are true, both are called
after the component is rendered only one a bit later then the other. I
guess the javadoc of the component should state that this is after the
page is rendered

On 5/18/08, Eyal Golan [EMAIL PROTECTED] wrote:
 ok.
 But, looking at the Javadoc, this is what I see:
 In AbstractBehavior:
 /**
  * Called when a component that has this behavior coupled was rendered.
  *
  * @param component
  *the component that has this behavior coupled
  */
 public void onRendered(Component component)
 {
 }

 And in Component:
 /**
  * Called just after a component is rendered.
  */
 protected void onAfterRender()
 {
 setFlag(FLAG_AFTER_RENDERING, false);
 }

 It looks to me that according to the API Javadoc the output should be same.
 But it isn't.
 Am I misunderstanding something or there's a minor bug?

 On Sat, May 17, 2008 at 1:45 PM, Johan Compagner [EMAIL PROTECTED]
 wrote:

 No the after render of a component is called after the page render to
 clean up stuff.
 Just as onBeforeRender is called before the page is starting to render

 On 5/17/08, Eyal Golan [EMAIL PROTECTED] wrote:
  Isn't this is what I did?
  Anyway, here's an example of what I get.
  First: the Java code:
  public final class TestButtonPage extends WebPage {
  public TestButtonPage() {
  add(new ExtendingButton(extendingButton));
  Button other = new Button(behavioralButton);
  other.add(new MyBehavior());
  add(other);
  }
 
  class ExtendingButton extends Button {
  private static final long serialVersionUID = 1L;
 
  public ExtendingButton(String id) {
  super(id);
  }
 
  @Override
  protected void onAfterRender() {
 
  getResponse().write(spanExtendingButton.onAfterRender()/span);
  super.onAfterRender();
  }
  }
 
  class MyBehavior extends AbstractBehavior {
  private static final long serialVersionUID = 1L;
 
  @Override
  public void onRendered(Component component) {
 
 
 component.getResponse().write(spanAbstractBehavior.onRendered(...)/span);
  }
  }
  }
 
  This is the markup:
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
  html xmlns=http://www.w3.org/1999/xhtml;
  xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
  head
  titleButton Test/title
  /head
  body
  button wicket:id=extendingButtonExtending Button/buttonbr/
  button wicket:id=behavioralButtonBehavioral Button/buttonbr/
  /body
  br /
  spanThis is just before the html closing tag/span
  br /
  /html
 
  And this is the output (taken from view source in my FF browser):
 
  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
  html xmlns=http://www.w3.org/1999/xhtml;
xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
  head
  titleButton Test/title
  /head
  body
  button id=extendingButton1 name=extendingButton
  wicket:id=extendingButtonExtending Button/buttonbr/
  button id=behavioralButton2 name=behavioralButton
  wicket:id=behavioralButtonBehavioral
  Button/buttonspanAbstractBehavior.onRendered(...)/spanbr/
  /body
  br /
  spanThis is just before the html closing tag/span
  br /
 
  /html
 
  spanExtendingButton.onAfterRender()/span
 
  As you can see, the behavior put the span tag just after the button,
 but
  the extendingButton put the span tag after the closing tag of the
 html.
 
  Is this the correct behavior?
 
  thanks
 
  On Thu, May 15, 2008 at 4:38 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
  get the components markupid from the component itself.
 
  johan
 
 
  On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED] wrote:
 
   thanks,
   that's exactly what I did.
   I add to my component (button) an AbstarctBehavior, which is an
   IHeaderContributor.
   I even override renderHead:
  @Override
  public void renderHead(IHeaderResponse response) {
  
  
 response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);
  
  
  
 
 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
   //response.renderJavascriptReference(new
   JavascriptResourceReference(
   //EurekifyButtonBehavior.class, resizeScript.js));
  }
  
   The script I am adding to each button comes from a utility class:
  static String getResizeScript(String markupId) {
  StringBuilder strBuilder = new StringBuilder();
  strBuilder.append(script language=\javascript\);
  strBuilder.append(document.getElementById('btnObj_);
  strBuilder.append(markupId);
  strBuilder.append(').style.width = calcBtnSize(');
  

Re: after render using a behavior vs. override in the component

2008-05-18 Thread Eyal Golan
Thanks.

:)

On Sun, May 18, 2008 at 10:08 AM, Johan Compagner [EMAIL PROTECTED]
wrote:

 No no bug just java doc isnt clear enough i guess, but it is not
 really wrong.. What is after render? Both are true, both are called
 after the component is rendered only one a bit later then the other. I
 guess the javadoc of the component should state that this is after the
 page is rendered

 On 5/18/08, Eyal Golan [EMAIL PROTECTED] wrote:
  ok.
  But, looking at the Javadoc, this is what I see:
  In AbstractBehavior:
  /**
   * Called when a component that has this behavior coupled was
 rendered.
   *
   * @param component
   *the component that has this behavior coupled
   */
  public void onRendered(Component component)
  {
  }
 
  And in Component:
  /**
   * Called just after a component is rendered.
   */
  protected void onAfterRender()
  {
  setFlag(FLAG_AFTER_RENDERING, false);
  }
 
  It looks to me that according to the API Javadoc the output should be
 same.
  But it isn't.
  Am I misunderstanding something or there's a minor bug?
 
  On Sat, May 17, 2008 at 1:45 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
  No the after render of a component is called after the page render to
  clean up stuff.
  Just as onBeforeRender is called before the page is starting to render
 
  On 5/17/08, Eyal Golan [EMAIL PROTECTED] wrote:
   Isn't this is what I did?
   Anyway, here's an example of what I get.
   First: the Java code:
   public final class TestButtonPage extends WebPage {
   public TestButtonPage() {
   add(new ExtendingButton(extendingButton));
   Button other = new Button(behavioralButton);
   other.add(new MyBehavior());
   add(other);
   }
  
   class ExtendingButton extends Button {
   private static final long serialVersionUID = 1L;
  
   public ExtendingButton(String id) {
   super(id);
   }
  
   @Override
   protected void onAfterRender() {
  
   getResponse().write(spanExtendingButton.onAfterRender()/span);
   super.onAfterRender();
   }
   }
  
   class MyBehavior extends AbstractBehavior {
   private static final long serialVersionUID = 1L;
  
   @Override
   public void onRendered(Component component) {
  
  
 
 component.getResponse().write(spanAbstractBehavior.onRendered(...)/span);
   }
   }
   }
  
   This is the markup:
   !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
   html xmlns=http://www.w3.org/1999/xhtml;
   xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
   head
   titleButton Test/title
   /head
   body
   button wicket:id=extendingButtonExtending Button/buttonbr/
   button wicket:id=behavioralButtonBehavioral Button/buttonbr/
   /body
   br /
   spanThis is just before the html closing tag/span
   br /
   /html
  
   And this is the output (taken from view source in my FF browser):
  
   !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
   html xmlns=http://www.w3.org/1999/xhtml;
 xmlns:wicket=http://wicket.apache.org/; xml:lang=en
 lang=en
   head
   titleButton Test/title
   /head
   body
   button id=extendingButton1 name=extendingButton
   wicket:id=extendingButtonExtending Button/buttonbr/
   button id=behavioralButton2 name=behavioralButton
   wicket:id=behavioralButtonBehavioral
   Button/buttonspanAbstractBehavior.onRendered(...)/spanbr/
   /body
   br /
   spanThis is just before the html closing tag/span
   br /
  
   /html
  
   spanExtendingButton.onAfterRender()/span
  
   As you can see, the behavior put the span tag just after the button,
  but
   the extendingButton put the span tag after the closing tag of the
  html.
  
   Is this the correct behavior?
  
   thanks
  
   On Thu, May 15, 2008 at 4:38 PM, Johan Compagner 
 [EMAIL PROTECTED]
   wrote:
  
   get the components markupid from the component itself.
  
   johan
  
  
   On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED]
 wrote:
  
thanks,
that's exactly what I did.
I add to my component (button) an AbstarctBehavior, which is an
IHeaderContributor.
I even override renderHead:
   @Override
   public void renderHead(IHeaderResponse response) {
   
   
 
 response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);
   
   
   
  
 
 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
//response.renderJavascriptReference(new
JavascriptResourceReference(
//EurekifyButtonBehavior.class,
 resizeScript.js));
   }
   
The script I am adding to each button comes from a utility class:
   static String getResizeScript(String markupId) {
   StringBuilder strBuilder = new 

Re: after render using a behavior vs. override in the component

2008-05-17 Thread Eyal Golan
Isn't this is what I did?
Anyway, here's an example of what I get.
First: the Java code:
public final class TestButtonPage extends WebPage {
public TestButtonPage() {
add(new ExtendingButton(extendingButton));
Button other = new Button(behavioralButton);
other.add(new MyBehavior());
add(other);
}

class ExtendingButton extends Button {
private static final long serialVersionUID = 1L;

public ExtendingButton(String id) {
super(id);
}

@Override
protected void onAfterRender() {

getResponse().write(spanExtendingButton.onAfterRender()/span);
super.onAfterRender();
}
}

class MyBehavior extends AbstractBehavior {
private static final long serialVersionUID = 1L;

@Override
public void onRendered(Component component) {

component.getResponse().write(spanAbstractBehavior.onRendered(...)/span);
}
}
}

This is the markup:
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
head
titleButton Test/title
/head
body
button wicket:id=extendingButtonExtending Button/buttonbr/
button wicket:id=behavioralButtonBehavioral Button/buttonbr/
/body
br /
spanThis is just before the html closing tag/span
br /
/html

And this is the output (taken from view source in my FF browser):

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
head
titleButton Test/title
/head
body
button id=extendingButton1 name=extendingButton
wicket:id=extendingButtonExtending Button/buttonbr/
button id=behavioralButton2 name=behavioralButton
wicket:id=behavioralButtonBehavioral
Button/buttonspanAbstractBehavior.onRendered(...)/spanbr/
/body
br /
spanThis is just before the html closing tag/span
br /

/html

spanExtendingButton.onAfterRender()/span

As you can see, the behavior put the span tag just after the button, but
the extendingButton put the span tag after the closing tag of the html.

Is this the correct behavior?

thanks

On Thu, May 15, 2008 at 4:38 PM, Johan Compagner [EMAIL PROTECTED]
wrote:

 get the components markupid from the component itself.

 johan


 On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED] wrote:

  thanks,
  that's exactly what I did.
  I add to my component (button) an AbstarctBehavior, which is an
  IHeaderContributor.
  I even override renderHead:
 @Override
 public void renderHead(IHeaderResponse response) {
 
  response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);
 
 
 
 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
  //response.renderJavascriptReference(new
  JavascriptResourceReference(
  //EurekifyButtonBehavior.class, resizeScript.js));
 }
 
  The script I am adding to each button comes from a utility class:
 static String getResizeScript(String markupId) {
 StringBuilder strBuilder = new StringBuilder();
 strBuilder.append(script language=\javascript\);
 strBuilder.append(document.getElementById('btnObj_);
 strBuilder.append(markupId);
 strBuilder.append(').style.width = calcBtnSize(');
 strBuilder.append(markupId).append('));
 strBuilder.append(/script);
 return strBuilder.toString();
 }
 
  This is the script that I mentioned in my first question.
 
  Again:
  If I call this script in the Button class, in the onAfterRender() method,
  it
  is added to the end of the output HTML.
  If I call this in the behavior, in the onRendered(Component component),
 it
  is added just after the /button.
 
  I did something like this in the onload script:
  window.onload = function(id) {
   document.getElementById('btnObj_'+id).style.width =  function(id)
  {calcBtnSize(id)};
  }
 
  firebug says that it can't find document.getElementById('btnObj_'+id) ...
  On Thu, May 15, 2008 at 3:50 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
   you can also do it on component
   public void renderHead(final HtmlHeaderContainer container)
  
   or let the component implement IHeaderContributor
  
   i guess that renderHead(final HtmlHeaderContainer container) shouldnt
 be
   public but more protected or final..
  
   johan
  
  
   On Thu, May 15, 2008 at 2:44 PM, Eyal Golan [EMAIL PROTECTED]
 wrote:
  
ok. thank, I'll try it (though I have never written JavaScript till a
  few
days ago...)
BTW, why is the difference between the overriding method and the
  behavior
method?
   
On Thu, May 15, 2008 at 2:52 PM, Johan Compagner 
 [EMAIL PROTECTED]
  
wrote:
   
 use a behavior that adds an onDocumentLoad/Ready script to the
  browser

 

Re: after render using a behavior vs. override in the component

2008-05-17 Thread Johan Compagner
No the after render of a component is called after the page render to
clean up stuff.
Just as onBeforeRender is called before the page is starting to render

On 5/17/08, Eyal Golan [EMAIL PROTECTED] wrote:
 Isn't this is what I did?
 Anyway, here's an example of what I get.
 First: the Java code:
 public final class TestButtonPage extends WebPage {
 public TestButtonPage() {
 add(new ExtendingButton(extendingButton));
 Button other = new Button(behavioralButton);
 other.add(new MyBehavior());
 add(other);
 }

 class ExtendingButton extends Button {
 private static final long serialVersionUID = 1L;

 public ExtendingButton(String id) {
 super(id);
 }

 @Override
 protected void onAfterRender() {

 getResponse().write(spanExtendingButton.onAfterRender()/span);
 super.onAfterRender();
 }
 }

 class MyBehavior extends AbstractBehavior {
 private static final long serialVersionUID = 1L;

 @Override
 public void onRendered(Component component) {

 component.getResponse().write(spanAbstractBehavior.onRendered(...)/span);
 }
 }
 }

 This is the markup:
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
 head
 titleButton Test/title
 /head
 body
 button wicket:id=extendingButtonExtending Button/buttonbr/
 button wicket:id=behavioralButtonBehavioral Button/buttonbr/
 /body
 br /
 spanThis is just before the html closing tag/span
 br /
 /html

 And this is the output (taken from view source in my FF browser):

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
   xmlns:wicket=http://wicket.apache.org/; xml:lang=en lang=en
 head
 titleButton Test/title
 /head
 body
 button id=extendingButton1 name=extendingButton
 wicket:id=extendingButtonExtending Button/buttonbr/
 button id=behavioralButton2 name=behavioralButton
 wicket:id=behavioralButtonBehavioral
 Button/buttonspanAbstractBehavior.onRendered(...)/spanbr/
 /body
 br /
 spanThis is just before the html closing tag/span
 br /

 /html

 spanExtendingButton.onAfterRender()/span

 As you can see, the behavior put the span tag just after the button, but
 the extendingButton put the span tag after the closing tag of the html.

 Is this the correct behavior?

 thanks

 On Thu, May 15, 2008 at 4:38 PM, Johan Compagner [EMAIL PROTECTED]
 wrote:

 get the components markupid from the component itself.

 johan


 On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED] wrote:

  thanks,
  that's exactly what I did.
  I add to my component (button) an AbstarctBehavior, which is an
  IHeaderContributor.
  I even override renderHead:
 @Override
 public void renderHead(IHeaderResponse response) {
 
  response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);
 
 
 
 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
  //response.renderJavascriptReference(new
  JavascriptResourceReference(
  //EurekifyButtonBehavior.class, resizeScript.js));
 }
 
  The script I am adding to each button comes from a utility class:
 static String getResizeScript(String markupId) {
 StringBuilder strBuilder = new StringBuilder();
 strBuilder.append(script language=\javascript\);
 strBuilder.append(document.getElementById('btnObj_);
 strBuilder.append(markupId);
 strBuilder.append(').style.width = calcBtnSize(');
 strBuilder.append(markupId).append('));
 strBuilder.append(/script);
 return strBuilder.toString();
 }
 
  This is the script that I mentioned in my first question.
 
  Again:
  If I call this script in the Button class, in the onAfterRender()
  method,
  it
  is added to the end of the output HTML.
  If I call this in the behavior, in the onRendered(Component component),
 it
  is added just after the /button.
 
  I did something like this in the onload script:
  window.onload = function(id) {
   document.getElementById('btnObj_'+id).style.width =  function(id)
  {calcBtnSize(id)};
  }
 
  firebug says that it can't find document.getElementById('btnObj_'+id)
  ...
  On Thu, May 15, 2008 at 3:50 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
   you can also do it on component
   public void renderHead(final HtmlHeaderContainer container)
  
   or let the component implement IHeaderContributor
  
   i guess that renderHead(final HtmlHeaderContainer container) shouldnt
 be
   public but more protected or final..
  
   johan
  
  
   On Thu, May 15, 2008 at 2:44 PM, Eyal Golan [EMAIL PROTECTED]
 wrote:
  
ok. thank, I'll try it (though I have never written JavaScript till
a
  few

Re: after render using a behavior vs. override in the component

2008-05-15 Thread Johan Compagner
use a behavior that adds an onDocumentLoad/Ready script to the browser

On Thu, May 15, 2008 at 12:35 PM, Eyal Golan [EMAIL PROTECTED] wrote:

 Hello,
 I have a MyButton that extends Button.
 I have a JavaScript that I need to ad to the output markup after the
 button's markup.
 I'm trying to do this with two differnet options:
 Either I Override onAfterRender in MyButton:
@Override
protected void onAfterRender() {
if (isVisible()) {
getResponse().write(Consts.getResizeScript(getMarkupId()));
}
super.onAfterRender();
}

 Or, I add to the button a behavior and write this:
@Override
public void onRendered(Component component) {
if (component.isVisible()) {


 component.getResponse().write(Consts.getResizeScript(component.getMarkupId()));
}

}

 Now, the situation is like this:
 Using the first option (override in the component), the script is added to
 the end of the html. Just after the /html
 Using the second option (the behavior), the script is added just after the
 close tag of the button /button.

 Using FF, all is ok, but in IE7, there's a problem in calculating the size
 and the button is not shown correctly.

 What causes the differences? and how can I manipulate the behavior to work
 like option 1 ?

 Thanks very much...

 --
 Eyal Golan
 [EMAIL PROTECTED]

 Visit: http://jvdrums.sourceforge.net/



Re: after render using a behavior vs. override in the component

2008-05-15 Thread Eyal Golan
ok. thank, I'll try it (though I have never written JavaScript till a few
days ago...)
BTW, why is the difference between the overriding method and the behavior
method?

On Thu, May 15, 2008 at 2:52 PM, Johan Compagner [EMAIL PROTECTED]
wrote:

 use a behavior that adds an onDocumentLoad/Ready script to the browser

 On Thu, May 15, 2008 at 12:35 PM, Eyal Golan [EMAIL PROTECTED] wrote:

  Hello,
  I have a MyButton that extends Button.
  I have a JavaScript that I need to ad to the output markup after the
  button's markup.
  I'm trying to do this with two differnet options:
  Either I Override onAfterRender in MyButton:
 @Override
 protected void onAfterRender() {
 if (isVisible()) {
 getResponse().write(Consts.getResizeScript(getMarkupId()));
 }
 super.onAfterRender();
 }
 
  Or, I add to the button a behavior and write this:
 @Override
 public void onRendered(Component component) {
 if (component.isVisible()) {
 
 
 
 component.getResponse().write(Consts.getResizeScript(component.getMarkupId()));
 }
 
 }
 
  Now, the situation is like this:
  Using the first option (override in the component), the script is added
 to
  the end of the html. Just after the /html
  Using the second option (the behavior), the script is added just after
 the
  close tag of the button /button.
 
  Using FF, all is ok, but in IE7, there's a problem in calculating the
 size
  and the button is not shown correctly.
 
  What causes the differences? and how can I manipulate the behavior to
 work
  like option 1 ?
 
  Thanks very much...
 
  --
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: http://jvdrums.sourceforge.net/
 




-- 
Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/


Re: after render using a behavior vs. override in the component

2008-05-15 Thread Johan Compagner
you can also do it on component
public void renderHead(final HtmlHeaderContainer container)

or let the component implement IHeaderContributor

i guess that renderHead(final HtmlHeaderContainer container) shouldnt be
public but more protected or final..

johan


On Thu, May 15, 2008 at 2:44 PM, Eyal Golan [EMAIL PROTECTED] wrote:

 ok. thank, I'll try it (though I have never written JavaScript till a few
 days ago...)
 BTW, why is the difference between the overriding method and the behavior
 method?

 On Thu, May 15, 2008 at 2:52 PM, Johan Compagner [EMAIL PROTECTED]
 wrote:

  use a behavior that adds an onDocumentLoad/Ready script to the browser
 
  On Thu, May 15, 2008 at 12:35 PM, Eyal Golan [EMAIL PROTECTED] wrote:
 
   Hello,
   I have a MyButton that extends Button.
   I have a JavaScript that I need to ad to the output markup after the
   button's markup.
   I'm trying to do this with two differnet options:
   Either I Override onAfterRender in MyButton:
  @Override
  protected void onAfterRender() {
  if (isVisible()) {
  getResponse().write(Consts.getResizeScript(getMarkupId()));
  }
  super.onAfterRender();
  }
  
   Or, I add to the button a behavior and write this:
  @Override
  public void onRendered(Component component) {
  if (component.isVisible()) {
  
  
  
 
 component.getResponse().write(Consts.getResizeScript(component.getMarkupId()));
  }
  
  }
  
   Now, the situation is like this:
   Using the first option (override in the component), the script is added
  to
   the end of the html. Just after the /html
   Using the second option (the behavior), the script is added just after
  the
   close tag of the button /button.
  
   Using FF, all is ok, but in IE7, there's a problem in calculating the
  size
   and the button is not shown correctly.
  
   What causes the differences? and how can I manipulate the behavior to
  work
   like option 1 ?
  
   Thanks very much...
  
   --
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: http://jvdrums.sourceforge.net/
  
 



 --
 Eyal Golan
 [EMAIL PROTECTED]

 Visit: http://jvdrums.sourceforge.net/



Re: after render using a behavior vs. override in the component

2008-05-15 Thread Eyal Golan
thanks,
that's exactly what I did.
I add to my component (button) an AbstarctBehavior, which is an
IHeaderContributor.
I even override renderHead:
@Override
public void renderHead(IHeaderResponse response) {

response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);

response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
//response.renderJavascriptReference(new
JavascriptResourceReference(
//EurekifyButtonBehavior.class, resizeScript.js));
}

The script I am adding to each button comes from a utility class:
static String getResizeScript(String markupId) {
StringBuilder strBuilder = new StringBuilder();
strBuilder.append(script language=\javascript\);
strBuilder.append(document.getElementById('btnObj_);
strBuilder.append(markupId);
strBuilder.append(').style.width = calcBtnSize(');
strBuilder.append(markupId).append('));
strBuilder.append(/script);
return strBuilder.toString();
}

This is the script that I mentioned in my first question.

Again:
If I call this script in the Button class, in the onAfterRender() method, it
is added to the end of the output HTML.
If I call this in the behavior, in the onRendered(Component component), it
is added just after the /button.

I did something like this in the onload script:
window.onload = function(id) {
  document.getElementById('btnObj_'+id).style.width =  function(id)
{calcBtnSize(id)};
}

firebug says that it can't find document.getElementById('btnObj_'+id) ...
On Thu, May 15, 2008 at 3:50 PM, Johan Compagner [EMAIL PROTECTED]
wrote:

 you can also do it on component
 public void renderHead(final HtmlHeaderContainer container)

 or let the component implement IHeaderContributor

 i guess that renderHead(final HtmlHeaderContainer container) shouldnt be
 public but more protected or final..

 johan


 On Thu, May 15, 2008 at 2:44 PM, Eyal Golan [EMAIL PROTECTED] wrote:

  ok. thank, I'll try it (though I have never written JavaScript till a few
  days ago...)
  BTW, why is the difference between the overriding method and the behavior
  method?
 
  On Thu, May 15, 2008 at 2:52 PM, Johan Compagner [EMAIL PROTECTED]
  wrote:
 
   use a behavior that adds an onDocumentLoad/Ready script to the browser
  
   On Thu, May 15, 2008 at 12:35 PM, Eyal Golan [EMAIL PROTECTED]
 wrote:
  
Hello,
I have a MyButton that extends Button.
I have a JavaScript that I need to ad to the output markup after the
button's markup.
I'm trying to do this with two differnet options:
Either I Override onAfterRender in MyButton:
   @Override
   protected void onAfterRender() {
   if (isVisible()) {
   
  getResponse().write(Consts.getResizeScript(getMarkupId()));
   }
   super.onAfterRender();
   }
   
Or, I add to the button a behavior and write this:
   @Override
   public void onRendered(Component component) {
   if (component.isVisible()) {
   
   
   
  
 
 component.getResponse().write(Consts.getResizeScript(component.getMarkupId()));
   }
   
   }
   
Now, the situation is like this:
Using the first option (override in the component), the script is
 added
   to
the end of the html. Just after the /html
Using the second option (the behavior), the script is added just
 after
   the
close tag of the button /button.
   
Using FF, all is ok, but in IE7, there's a problem in calculating the
   size
and the button is not shown correctly.
   
What causes the differences? and how can I manipulate the behavior to
   work
like option 1 ?
   
Thanks very much...
   
--
Eyal Golan
[EMAIL PROTECTED]
   
Visit: http://jvdrums.sourceforge.net/
   
  
 
 
 
  --
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: http://jvdrums.sourceforge.net/
 




-- 
Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/


Re: after render using a behavior vs. override in the component

2008-05-15 Thread Johan Compagner
get the components markupid from the component itself.

johan


On Thu, May 15, 2008 at 3:03 PM, Eyal Golan [EMAIL PROTECTED] wrote:

 thanks,
 that's exactly what I did.
 I add to my component (button) an AbstarctBehavior, which is an
 IHeaderContributor.
 I even override renderHead:
@Override
public void renderHead(IHeaderResponse response) {

 response.renderCSSReference(/eurekify/style/button/EurekifyButton.css);


 response.renderJavascriptReference(/eurekify/style/button/EurekifyButton.js);
 //response.renderJavascriptReference(new
 JavascriptResourceReference(
 //EurekifyButtonBehavior.class, resizeScript.js));
}

 The script I am adding to each button comes from a utility class:
static String getResizeScript(String markupId) {
StringBuilder strBuilder = new StringBuilder();
strBuilder.append(script language=\javascript\);
strBuilder.append(document.getElementById('btnObj_);
strBuilder.append(markupId);
strBuilder.append(').style.width = calcBtnSize(');
strBuilder.append(markupId).append('));
strBuilder.append(/script);
return strBuilder.toString();
}

 This is the script that I mentioned in my first question.

 Again:
 If I call this script in the Button class, in the onAfterRender() method,
 it
 is added to the end of the output HTML.
 If I call this in the behavior, in the onRendered(Component component), it
 is added just after the /button.

 I did something like this in the onload script:
 window.onload = function(id) {
  document.getElementById('btnObj_'+id).style.width =  function(id)
 {calcBtnSize(id)};
 }

 firebug says that it can't find document.getElementById('btnObj_'+id) ...
 On Thu, May 15, 2008 at 3:50 PM, Johan Compagner [EMAIL PROTECTED]
 wrote:

  you can also do it on component
  public void renderHead(final HtmlHeaderContainer container)
 
  or let the component implement IHeaderContributor
 
  i guess that renderHead(final HtmlHeaderContainer container) shouldnt be
  public but more protected or final..
 
  johan
 
 
  On Thu, May 15, 2008 at 2:44 PM, Eyal Golan [EMAIL PROTECTED] wrote:
 
   ok. thank, I'll try it (though I have never written JavaScript till a
 few
   days ago...)
   BTW, why is the difference between the overriding method and the
 behavior
   method?
  
   On Thu, May 15, 2008 at 2:52 PM, Johan Compagner [EMAIL PROTECTED]
 
   wrote:
  
use a behavior that adds an onDocumentLoad/Ready script to the
 browser
   
On Thu, May 15, 2008 at 12:35 PM, Eyal Golan [EMAIL PROTECTED]
  wrote:
   
 Hello,
 I have a MyButton that extends Button.
 I have a JavaScript that I need to ad to the output markup after
 the
 button's markup.
 I'm trying to do this with two differnet options:
 Either I Override onAfterRender in MyButton:
@Override
protected void onAfterRender() {
if (isVisible()) {

   getResponse().write(Consts.getResizeScript(getMarkupId()));
}
super.onAfterRender();
}

 Or, I add to the button a behavior and write this:
@Override
public void onRendered(Component component) {
if (component.isVisible()) {



   
  
 
 component.getResponse().write(Consts.getResizeScript(component.getMarkupId()));
}

}

 Now, the situation is like this:
 Using the first option (override in the component), the script is
  added
to
 the end of the html. Just after the /html
 Using the second option (the behavior), the script is added just
  after
the
 close tag of the button /button.

 Using FF, all is ok, but in IE7, there's a problem in calculating
 the
size
 and the button is not shown correctly.

 What causes the differences? and how can I manipulate the behavior
 to
work
 like option 1 ?

 Thanks very much...

 --
 Eyal Golan
 [EMAIL PROTECTED]

 Visit: http://jvdrums.sourceforge.net/

   
  
  
  
   --
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: http://jvdrums.sourceforge.net/
  
 



 --
 Eyal Golan
 [EMAIL PROTECTED]

 Visit: http://jvdrums.sourceforge.net/