

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
16 messages in org.apache.wicket.usersComponent parent null after replace| From | Sent On | Attachments |
|---|---|---|
| Anthony Schexnaildre | Sep 9, 2007 1:37 am | |
| Igor Vaynberg | Sep 9, 2007 9:08 am | |
| Maurice Marrink | Sep 9, 2007 10:12 am | |
| Anthony Schexnaildre | Sep 10, 2007 2:47 pm | |
| Anthony Schexnaildre | Sep 10, 2007 3:30 pm | |
| Maurice Marrink | Sep 11, 2007 1:11 am | |
| Martijn Dashorst | Sep 11, 2007 1:38 am | |
| Maurice Marrink | Sep 11, 2007 2:05 am | |
| Anthony Schexnaildre | Sep 11, 2007 8:07 am | |
| Martijn Dashorst | Sep 11, 2007 8:19 am | |
| Maurice Marrink | Sep 11, 2007 3:24 pm | |
| Anthony Schexnaildre | Sep 11, 2007 3:33 pm | |
| Anthony Schexnaildre | Sep 12, 2007 10:57 am | |
| Maurice Marrink | Sep 12, 2007 2:20 pm | |
| wicketnewuser | Oct 22, 2009 11:05 pm | |
| Pedro Santos | Oct 23, 2009 11:25 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Component parent null after replace | Actions... |
|---|---|---|
| From: | Anthony Schexnaildre (apsc...@gmail.com) | |
| Date: | Sep 9, 2007 1:37:13 am | |
| List: | org.apache.wicket.users | |
I am trying to create a link that will replace one panel with another on the page. This seems as though it should be an easy task but after many attempts and searching the net for examples I have yet to get it working so the replacement can happen more than one without the component becoming orphaned. On the second replace attempt i get the following exception. Anyone have the solution?
Thank you,
Anthony
java.lang.IllegalStateException: This method can only be called on a component that has already been added to its parent. at org.apache.wicket.Component.replaceWith(Component.java:2266) at com.pinwise.pinbase.web.components.links.SecurePanelLink $4.onClick(SecurePanelLink.java:142) at org.apache.wicket.markup.html.link.Link.onLinkClicked (Link.java:222) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.wicket.RequestListenerInterface.invoke (RequestListenerInterface.java:186)
=====================================
=====================================
public UserPanel(String id) { super(id);
UserFormPanel userFormPanel = new UserFormPanel("userFormPanel"); add( userFormPanel );
List<IColumn> columns = new ArrayList<IColumn>(); final Model m = new Model(userFormPanel); columns.add(new PropertyColumn(new Model("Actions"), "id") { public void populateItem(Item cellItem, String componentId, final IModel model) { EditActionPanel panel = new EditActionPanel(componentId, model); panel.add( SecurePanelLink.createSecurePanelLink( "edit", m, UserFormPanel.class, model ) ); cellItem.add( panel ); } });
columns.add(new PropertyColumn(new Model("Username"), "username", "username")); columns.add(new PropertyColumn(new Model("First Name"), "firstName", "firstName")); columns.add(new PropertyColumn(new Model("Last Name"), "lastName", "lastName"));
add(new DefaultDataTable("table", columns, new SortableUserDataProvider(), 10)); }
==================================== SecurePanelLink ==================================== public class SecurePanelLink extends Link implements ISecureComponent {
/** * */ private static final long serialVersionUID = 1L;
protected IPanelLink panelLink;
/** * @param id * @param c */ public SecurePanelLink(String id, final Class c) { super(id); // Ensure that c is a subclass of Panel if (!Panel.class.isAssignableFrom(c)) { throw new IllegalArgumentException("Class " + c + " is not a subclass of Panel"); }
this.panelLink = createIPanelLink( id, c ); setSecurityCheck(new LinkSecurityCheck(this, c)); }
public SecurePanelLink(String id, final Class c, Model existingPanel) { super(id); // Ensure that c is a subclass of Panel if (!Panel.class.isAssignableFrom(c)) { throw new IllegalArgumentException("Class " + c + " is not a subclass of Panel"); }
this.panelLink = createIPanelLink( id, c ); setSecurityCheck(new LinkSecurityCheck(this, c)); }
private IPanelLink createIPanelLink( String id, final Class c ) { return new IPanelLink() { private static final long serialVersionUID = 1L;
public Panel getPanel( String id ) { // Create panel using panel factory return getPanelFactory().newPanel(id, c ); }
public Panel getPanel( String id, IModel model) { // Create panel using panel factory return getPanelFactory().newPanel(id, c, model); }
public Panel getPanel( Panel panel, IModel model) { // Create panel using panel factory return getPanelFactory().newPanel(panel.getId(), c, model); }
public Class getPanelIdentity() { return c; } }; }
/** * */ public static SecurePanelLink createSecurePanelLink( String id, Class clazz ) { return new SecurePanelLink( id, clazz ) { /** * */ private static final long serialVersionUID = 1L;
public void onClick() { Panel panel = ((Panel)findParent(Panel.class)); panel.replaceWith( panelLink.getPanel( panel.getId() ) ); } }; }
/** * */ public static SecurePanelLink createSecurePanelLink( String id, Class newPanel, final IModel model ) { return new SecurePanelLink( id, newPanel ) { /** * */ private static final long serialVersionUID = 1L;
public void onClick() { Panel panel = ((Panel)findParent(Panel.class)); panel.replaceWith( panelLink.getPanel( panel.getId(), model ) ); } }; }
/** * */ public static SecurePanelLink createSecurePanelLink( String id, final Model existingPanel, Class newPanel, final IModel model ) { return new SecurePanelLink( id, newPanel, existingPanel ) { /** * */ private static final long serialVersionUID = 1L;
public void onClick() { Panel p = (Panel)existingPanel.getObject(); Panel panel = panelLink.getPanel((Panel)existingPanel.getObject (), model ); panel.setOutputMarkupId(true); p.getParent().replace( panel ); p=panel; } }; }







