You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nquirynen <na...@pensionarchitects.be> on 2012/05/02 10:37:02 UTC

Sidepanel with pagespecific items

Hi,

In my current project I want to add some kind of side bar with some extra
functions/data in the form of icons with a panel that slides open
(javascript). These items can be global or more page specific. Example:

Search: visible on every page
Notes: visible on specific pages, containing data based on a Person object
Errors: only visible on dashboard page, based on Policy object

The visual styling html/css/jquery are no problem, but I don't know how to
implement this with Tapestry.
Does anyone have some guidelines on how to start this?

I made a component SideBar and added it to my Layout component. Then I
thought of adding Block items to this component, but I'm not sure how to add
these from within a page. 

So in short: no idea how to start on this; any hints are appreciated.

Thanks, 
Nathan

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Sidepanel-with-pagespecific-items-tp5679939.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Sidepanel with pagespecific items

Posted by Lance Java <la...@googlemail.com>.
Given your example... The Simulation and Dashboard pages could implement
PolicyProvider

Then, in your Layout

public class Layout {
   @InjectPage
   private Page page;

   public Policy getPolicy() {
      if (page instanceof PolicyProvider) {
         return ((PolicyProvider) page).getPolicy();
      }
      return null;
   }
}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Sidepanel-with-pagespecific-items-tp5679939p5680495.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Sidepanel with pagespecific items

Posted by Lance Java <la...@googlemail.com>.
I'm not 100% exactly what you're trying to do but it sounds like you should
make components for the bits you want to re-use and then pass a block
parameter to the layout.

Take a look at the RenderCommand class too. This is a way of providing
markup programatically and it may make sense for you to use a RenderCommand
parameter instead. You can use Tapestry's type coercion to convert from
Block to RenderCommand.

Inheritance is almost always a bad idea and more often than not, there is a
more elegant way of doing it in tapestry. Pages and components can implement
interfaces, but the interfaces MUST must not be in the pages or components
packages.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Sidepanel-with-pagespecific-items-tp5679939p5680458.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Sidepanel with pagespecific items

Posted by nquirynen <na...@pensionarchitects.be>.
Hi,

Thanks that's what I needed. I have now the global items in my Layout
component. And I can add some from within a Page as a parameter.

My code at the moment (simplified):

*Layout.tml:*

<div id="sidePanel">
[items that are shown on every page]
<t:delegate to="sidePanelContent" />
</div>

*Layout.java:*

@Parameter
private Block sidePanel;

public Object getSidePanelContent() {
		return sidePanel;
}

*Dashboard.tml:*

<p:sidePanel>
     ${policy.holder.name}
</p:sidePanel>

*Dashboard.java*

@Property
private Policy policy;

Object onActivate(Policy policy) {
     this.policy = policy;
}


This works...
Now what if I have another page, lets say "Simulation". And I want to add
that same content as a parameter like in "Dashboard". How can I reuse this
code instead of adding this in every page I want to show this in.

I've tried making an extra component between the Layout and the Page where I
put the common content to be added in a parameter. But then I had a problem
accessing needed properties from my pages (policy in my example)

Then I thought I could use inheritance and put the onActivate method in the
parent class. But I think that's not gonna solve my problem...

Maybe I should just create a component for each type of content I want to
add to the sidePanel and in every page add the wanted components..?



Hope you understand what I meant in my above rant and can give your thoughts
on this.

Thanks

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Sidepanel-with-pagespecific-items-tp5679939p5680371.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Sidepanel with pagespecific items

Posted by Lance Java <la...@googlemail.com>.
The example here  http://wiki.apache.org/tapestry/Tapestry5Layoutcomponent
http://wiki.apache.org/tapestry/Tapestry5Layoutcomponent  shows how to use
the delegate component to have a default "left" block which can be
overridden.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Sidepanel-with-pagespecific-items-tp5679939p5679984.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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