Hi,
 Im creating a Decorator/Wrapper Panel that will show EDIT/DELETE options on
the content if the user is authorized to do so.

The markup simply put, is like this:

<?xml version="1.0" encoding="utf-8"?>
<html>
        <body>
                <wicket:panel>
                        <table>
                                <tr><td> DELETE </td><td> EDIT </td></tr>
                                <tr><td colspan=2><div
wicket:id='container'><***TAG_TYPE***wicket:id='component'
/></div></td></tr>
                        </table>
                </wicket:panel>
        </body>
</html>



The issue is that the Wrapper by design can consume any Component and
decorate it. However, the TAG type depends on the component inserted. I'd
liek to control that programatically. Is there any way I can do that?

..the corresponding code is like :

public abstract class EditableComponentWrapper extends Panel {
        private static final long serialVersionUID = 1191322949129480444L;
        
        private boolean allowDelete, allowEdit;

  public EditableComponentWrapper(String id) {
    super( id );
    WebMarkupContainer container = new WebMarkupContainer("container");
    add(container); 
    container.add(addComponent("component"));
  }
  
  /**
   * Add custom Component to the container. Use the id passed to construct
the component.
   * 
   * @param componentId as String
   */
  public abstract Component addComponent(String componentId);
  
  public void onInitialize() {
          super.onInitialize();
          
          addOrReplace(new AjaxLink("delete") {         
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                                onDelete(target);
                        }
                }
            .setOutputMarkupId(true)
            .setEnabled(allowDelete)
            .setVisible(allowDelete));  
            
           addOrReplace(new AjaxLink("edit") {
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                                onEdit(target);                 
                        }               
                }
           .setOutputMarkupId(true)
           .setEnabled(allowEdit)
           .setVisible(allowEdit));
  }
...
...



-----
Don't take life too seriously, your'e not getting out it alive anyway!
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dynamic-Tag-substitution-tp3311189p3311189.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to