Hi Adr,

The markupid of any component is only assigned when the containing component is actually added into the page.

The way around this is that the AttributeModifier (and most other behaviours I believe) class actually renders the "onclick" event during the onComponentTag(..) method of the panel being rendered at which point the markup id's are set.

You can just wrap the javascript in a model that will generate the correct text string when getObject() is called.

My helper class for this case takes in a string and replaces a placeholder with the desired markupid when the getObject() method of IModel is called.

e.g. panel.add (new AttributeModifier ("onClick", new MarkupIDInStringModel ("var panel=document.getElementById('" + MarkupIDInStringModel.MARKUP_ID_PLACEHOLDER + "');panel.style.display=this.checked?'block':'none';", addLocationPanel));

so when the onComponentTag method is called the model inserts addLocationPanel.getMarkupID() into the placeholder value.

Regards,

Mike
I have moved my objects in Pnale to fields eg.:
public class RegisterUserPanel extends Panel {
        
        final CheckBox openClosePanelCheckBox;
        
        final Panel addLocationPanel;
...
}
and from Page I setup attributes:
RegisterUserPanel registerUserPanel = new
RegisterUserPanel("register_user_panel");
                add(registerUserPanel);
                registerUserPanel.openClosePanelCheckBox.add(new
SimpleAttributeModifier("onclick", "var
panel=document.getElementById('" +
registerUserPanel.addLocationPanel.getMarkupId() +
"');panel.style.display=this.checked?'block':'none';"));

But is this good way to follow? Any other pattern to use?

best regards,
Adr

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



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

Reply via email to