Re: DirectLink in Abstract Component

2006-10-12 Thread Norbert Sándor




If you must use AbstractComponent as subclass, try something
like:

public abstract class MyComponent extends AbstractComponent implements
IDirect
{
    ...

    public void renderComponent(...)
    {
  writer.begin("a");
  writer.attribute("href", getLink(cycle));

  writer.attribute("onmouseover", "hideAllButThis('pm_" + menu.getName()+"Menu', none');");
  // or use an equivalent dojo event listener - it is much more 4.1-style ;)

  writer.begin("span");
  writer.print(menu.getName());
  writer.end(); //end span
  writer.end(); // end a

    }

    // All below are copied from DirectLink

    public ILink getLink(IRequestCycle cycle)
    {
    Object[] serviceParameters =
constructServiceParameters(getParameters());   
    DirectServiceParameter dsp = new DirectServiceParameter(this,
serviceParameters);
    return getEngine().getLink(isStateful(), dsp);
    }

   ... [some other methods of DirectLink]
}

where getLink() is the same as you find in DirectLink.java (of course
you would need some supporting methods of the same class).
As you realized, writer outputs the final markup, so you cannot create
dynamic components (writing "jwcid" attribute will just result in a
"jwcid" attribute in the final HTML).


As I said, all the code above is only a sample implementation because
your component (and most compound components) is easier to implement
using a BaseComponent:

.jwc

    ...
    ...
    ...  <-- or
use dojo events by a Script component



    menu.name


.html




I hope this helps.

Regards,
Norbi

jake123 wrote:

  

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


  





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DirectLink in Abstract Component

2006-10-12 Thread jake123



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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DirectLink in Abstract Component

2006-10-11 Thread Norbert Sándor
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DirectLink in Abstract Component

2006-10-11 Thread jake123

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DirectLink in Abstract Component

2006-10-10 Thread jake123

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]