You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by FarhanS <fa...@gmail.com> on 2010/09/24 03:25:21 UTC

Making a DecoratedButton; Need to pre-fix/post-fix
tag around the button component

Hi Guys,

I am trying to make a reusable DecoratedButton component (extension of
wicket Button), which would draw itself with appropriate icon, color, and
other styles, based on the provided ButtonType, an enum e.g. 'Save', 'Edit',
'Delete', 'Search', 'Cancel' etc...

I am trying to find solution to; how to encapsulate the html (associated
with the button) in the form of wicket component to get the desired look &
feel. The html that represents the button is as below:


 <div class="buttons">
  <button type="submit">
      ./resources/Save.png Save
  </button>
 </div>


The html-button as you see above is encapsulated in a '<div>' tag. The
Button component (DecoratedButton) I am making, I want the user to use the
html <button> tag to attach the component to (instead of using <div> which
is the container tag in my implementation), as that is only intuitive, when
using a Button component.

Ok, so here is my question, how can i prefix/post-fix <div> tag or any other
tag, around the html <button> tag to which the new DecoratedButton component
will be attached to. I did think about the option of renaming the '<button>'
tag to '<div>' using setName in OnComponentTag() method, and than
appending/injecting the remaining html within it (e.g. the Button itself). 
But than what if the user has any other behaviors/style/attributes attached
to the button component, how would gather all those attributes from it to
the new button tag html i inject with the <div>..? It doesn't seem like the
right way to go ?

Any ideas/thoughts ?

Thanks in advance,

Farhan.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-a-DecoratedButton-Need-to-pre-fix-post-fix-div-tag-around-the-button-component-tp2552950p2552950.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Making a DecoratedButton; Need to pre-fix/post-fix
tag around the button component

Posted by Martin Grigorov <mg...@apache.org>.
attach AbstractBehavior to Button and override
org.apache.wicket.behavior.AbstractBehavior.beforeRender(Component)
org.apache.wicket.behavior.AbstractBehavior.onRendered(Component)

in their bodies write directly to the response:
RequestCycle.get().getResponse().write("your stuff")

On Fri, Sep 24, 2010 at 3:25 AM, FarhanS <fa...@gmail.com> wrote:

>
> Hi Guys,
>
> I am trying to make a reusable DecoratedButton component (extension of
> wicket Button), which would draw itself with appropriate icon, color, and
> other styles, based on the provided ButtonType, an enum e.g. 'Save',
> 'Edit',
> 'Delete', 'Search', 'Cancel' etc...
>
> I am trying to find solution to; how to encapsulate the html (associated
> with the button) in the form of wicket component to get the desired look &
> feel. The html that represents the button is as below:
>
>
>  <div class="buttons">
>  <button type="submit">
>      ./resources/Save.png Save
>  </button>
>  </div>
>
>
> The html-button as you see above is encapsulated in a '<div>' tag. The
> Button component (DecoratedButton) I am making, I want the user to use the
> html <button> tag to attach the component to (instead of using <div> which
> is the container tag in my implementation), as that is only intuitive, when
> using a Button component.
>
> Ok, so here is my question, how can i prefix/post-fix <div> tag or any
> other
> tag, around the html <button> tag to which the new DecoratedButton
> component
> will be attached to. I did think about the option of renaming the
> '<button>'
> tag to '<div>' using setName in OnComponentTag() method, and than
> appending/injecting the remaining html within it (e.g. the Button itself).
> But than what if the user has any other behaviors/style/attributes attached
> to the button component, how would gather all those attributes from it to
> the new button tag html i inject with the <div>..? It doesn't seem like the
> right way to go ?
>
> Any ideas/thoughts ?
>
> Thanks in advance,
>
> Farhan.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Making-a-DecoratedButton-Need-to-pre-fix-post-fix-div-tag-around-the-button-component-tp2552950p2552950.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Making a DecoratedButton; Need to pre-fix/post-fix
tag around the button component

Posted by Alexander Morozov <al...@gmail.com>.
Check out the artifactory code (http://www.jfrog.org/index.php) and check
TemplateBehavior class.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-a-DecoratedButton-Need-to-pre-fix-post-fix-div-tag-around-the-button-component-tp2552950p2553242.html
Sent from the Users forum mailing list archive at Nabble.com.

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