You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by MattyDE <uf...@gmail.com> on 2011/10/26 13:23:33 UTC

Re: Attribute Inheritance or Copying?

This is my updated version right know.

Its very dangerous to copy wicket:id and id. On ajax updating the component
get cloned and cloned and cloned...

public class CopyAttributesBehavior extends AbstractBehavior { 

  private static final long serialVersionUID = 1L; 
  private IValueMap attributes; 
  
  List<String> notAllowedAttributes = Arrays.asList("wicket:id", "id");

  @Override 
  public void onComponentTag(Component component, ComponentTag tag) { 
      if (attributes != null) {
      	
      	for(Entry<String, Object> entry : attributes.entrySet()){
      		if(!notAllowedAttributes.contains(entry.getKey())){
      			tag.getAttributes().put(entry.getKey(), entry.getValue());
      		}
      		
      	}
      }
  } 

  public IValueMap getAttributes() { 
      return attributes; 
  } 
  public void setAttributes(IValueMap attributes) { 
      this.attributes = attributes; 
  } 
} 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Attribute-Inheritance-or-Copying-tp3332828p3940229.html
Sent from the Users forum mailing list archive at Nabble.com.

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