You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Prag <pr...@gmail.com> on 2009/02/17 23:37:10 UTC

Add a surrounding component to itself

For a component (A) I would like to be able to add a surrounding component
(B) (a link) in some cases. Component A itself should be able to add
surrounding component B.

Example:
A product component in some cases has detailed info. If this is the case,
the product component should be linkable to the detailed page. If it's
linkable, the product component should add a surrounding link to itself to
the detailed page.


So the product component should be able to hide/add its parent without
itself become hidden.

How can I achieve this?
-- 
View this message in context: http://www.nabble.com/Add-a-surrounding-component-to-itself-tp22067906p22067906.html
Sent from the Wicket - User 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: Add a surrounding component to itself

Posted by Willis Blackburn <wb...@panix.com>.
Prag,

It would be tough to write a component that could "replace" itself,  
and I think that it's impossible to have a component that's visible  
when its parent is invisible.

What you want to do is create a Panel that either displays the link  
with the product within it, or just displays the product.  You'll  
probably want to use Fragment within the Panel, which will let you use  
a different bit of markup for each case while still keeping it in one  
HTML file.  You could also just create the components for both cases  
(a standalone Label and a Link containing a second Label) and just  
show one or the other.

W


On Feb 17, 2009, at 5:37 PM, Prag wrote:

>
> For a component (A) I would like to be able to add a surrounding  
> component
> (B) (a link) in some cases. Component A itself should be able to add
> surrounding component B.
>
> Example:
> A product component in some cases has detailed info. If this is the  
> case,
> the product component should be linkable to the detailed page. If it's
> linkable, the product component should add a surrounding link to  
> itself to
> the detailed page.
>
>
> So the product component should be able to hide/add its parent without
> itself become hidden.
>
> How can I achieve this?
> -- 
> View this message in context: http://www.nabble.com/Add-a-surrounding-component-to-itself-tp22067906p22067906.html
> Sent from the Wicket - User 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
>


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


Re: Add a surrounding component to itself

Posted by Jeremy Thomerson <je...@wickettraining.com>.
One option: Use a panel that contains both.  Rather than adding B, add the
panel, which knows to display one or both.


-- 
Jeremy Thomerson
http://www.wickettraining.com

On Tue, Feb 17, 2009 at 4:37 PM, Prag <pr...@gmail.com> wrote:

>
> For a component (A) I would like to be able to add a surrounding component
> (B) (a link) in some cases. Component A itself should be able to add
> surrounding component B.
>
> Example:
> A product component in some cases has detailed info. If this is the case,
> the product component should be linkable to the detailed page. If it's
> linkable, the product component should add a surrounding link to itself to
> the detailed page.
>
>
> So the product component should be able to hide/add its parent without
> itself become hidden.
>
> How can I achieve this?
> --
> View this message in context:
> http://www.nabble.com/Add-a-surrounding-component-to-itself-tp22067906p22067906.html
> Sent from the Wicket - User 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: Add a surrounding component to itself

Posted by Prag <pr...@gmail.com>.
I solved it by doing something this:


***** PRODUCT panel HTML *************
<wicket:panel>
	<wicket:container wicket:id="test">
	<div class="product">

	</div>
	</wicket:container>
</wicket:panel>


**** PRODUCT panel JAVA ************
		WebMarkupContainer test = new WebMarkupContainer("test") {
			@Override
			public void onRender(MarkupStream stream) {
				if (forSomeCondition) {
					getResponse().write(" \"someurl\" ");
				}
				
				renderComponent(stream);
				if (forSomeCondition) {
					getResponse().write(" ");
					
				}

			}
		};
		
		add(test);






Prag wrote:
> 
> For a component (A) I would like to be able to add a surrounding component
> (B) (a link) in some cases. Component A itself should be able to add
> surrounding component B.
> 
> Example:
> A product component in some cases has detailed info. If this is the case,
> the product component should be linkable to the detailed page. If it's
> linkable, the product component should add a surrounding link to itself to
> the detailed page.
> 
> 
> So the product component should be able to hide/add its parent without
> itself become hidden.
> 
> How can I achieve this?
> 

-- 
View this message in context: http://www.nabble.com/Add-a-surrounding-component-to-itself-tp22067906p22111910.html
Sent from the Wicket - User 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