You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jake123 <ja...@gmail.com> on 2006/10/10 23:12:01 UTC

DirectLink in Abstract Component

Hi,
I have a menu component that extends AbstractComponent. It seems that my
DirectLinks in the menu component does not work. I have 4 different Listener
methods and I have injected the pages that they should go to. If I add
sysout:s to se if I end upp in the listener methods nothing happens. I have
done this:

in MenuComp.java:

public abstract class MenuSystem extends AbstractComponent {

	/*  */
	@InjectState("sessionuserinfo")
	public abstract SessionUserInfo getSessionUserInfo();

	@InjectPage("HomeAction")
	public abstract HomeAction getHomePage();
	
	@InjectPage("ContactUsPage")
	public abstract ContactUsPage getContactUsPage();
	
	@InjectPage("ArticlePage")
	public abstract ArticlePage getArticlePage();

        @InjectPage("ArticleListPage")
	public abstract ArticleListPage getArticleListPage();

        @Override
	protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
        .....
        writer.begin("a");
	writer.attribute("jwcid", "@DirectLink");
	writer.attribute("listener", "listener:onClickDirectLinkHomePage" );
	writer.attribute("onmouseover", "hideAllButThis('none', 'none');");
	writer.attribute("href", "#");
	writer.begin("span");
	writer.print(menu.getName());
	writer.end(); // end span
	writer.end(); // end a
        ....
       }

       public HomeAction onClickDirectLinkHomePage() {
		return getHomePage();
	}
	
	public ContactUsPage onClickDirectLinkContactUsPage() {
		return getContactUsPage();
	}
	
	public ArticleListPage onClickDirectLinkArticleListPage(Long menuId) {
		getArticleListPage().setMenuId(menuId);
		return getArticleListPage();
	}
	
	public ArticlePage onClickDirectLinkArticlePage(Long articleId) {
		getArticlePage().setArticleId(articleId);
		return getArticlePage();
	}

}



The menu component is rendering correctly, but nothing happens when I try to
click on my DirectLinks. Hopefully I just missed something small, but I cant
see it...

Thanks
Jacob






	
-- 
View this message in context: http://www.nabble.com/DirectLink-in-Abstract-Component-tf2419541.html#a6745562
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: DirectLink in Abstract Component

Posted by jake123 <ja...@gmail.com>.


Norbert Sándor wrote:
> 
> What you can do (for example) is to implement IDirect in your component 
> (which extends AbstractComponent) and generate a link using the "direct" 
> service which will trigger that component.
> I recommend you to look at the source code of DirectComponent.
> 

Do you have any examples on how this works? I have realised that the way I
am trying to do it defenetly do not work. 
  writer.begin("a");
  writer.attribute("jwcid", "@DirectLink");
  writer.attribute("listener",
"ognl:listeners.onClickDirectLinkArticleListPage");
  writer.attribute("parameters", menu.getMenuId().intValue());
  writer.attribute("onmouseover", "hideAllButThis('pm_" + menu.getName()
+"Menu', none');");
  writer.attribute("href", "");
  writer.begin("span");
  writer.print(menu.getName());
  writer.end(); //end span
  writer.end(); // end a

becouse I put in jwcid:s and ognl etc in already generated html.

So the question is how can I generate the link and add that to the writer?
Thanks
Jacob


-- 
View this message in context: http://www.nabble.com/DirectLink-in-Abstract-Component-tf2419541.html#a6777695
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: DirectLink in Abstract Component

Posted by Norbert Sándor <de...@erinors.com>.
The DirectLink component is not that complex: it uses the "direct" 
service to create a link. When the user clicks on the link, the "direct" 
service handles  almost everything.

What you can do (for example) is to implement IDirect in your component 
(which extends AbstractComponent) and generate a link using the "direct" 
service which will trigger that component.
I recommend you to look at the source code of DirectComponent.

As I know you can define contained components in any component. So 
another solution is to define a DirectLink in your .jwc file and 
explicitly render it from the renderComponent() method of your custom 
component.

Regards,
Norbi

jake123 wrote:
> Please, 
> have anybody created a DirectLink in a Custom Component that extends from
> AbstractComponent? How do you do that?
> I could really need some pointers!
>
> Thanks in advance,
> Jacob
>   


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


Re: DirectLink in Abstract Component

Posted by jake123 <ja...@gmail.com>.
Please, 
have anybody created a DirectLink in a Custom Component that extends from
AbstractComponent? How do you do that?
I could really need some pointers!

Thanks in advance,
Jacob
-- 
View this message in context: http://www.nabble.com/DirectLink-in-Abstract-Component-tf2419541.html#a6761175
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