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
<component id="link" type="DirectLink">
    <binding name="listener">...</binding>
    <binding name="parameters">...</binding>
    <binding name="onmouseover">...</binding>  <-- or use dojo events by a Script component
</component>

<component id="insertMenuName" type="Insert">
    <binding name="value">menu.name</binding>
</component>

.html

<a jwcid="link"><span><span jwcid="insertMenuName" /></span></a>


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]

Reply via email to