You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Paul Bors <pa...@bors.ws> on 2013/08/01 00:34:14 UTC

RE: How to add line breaks in the summary text of Wizard properties file

The way I styled the wizard to fit my look-n-feel is by extending Wizard and
creating MyOwnWizard and then overriding whatever I wanted to change in the
Java code (such as the type of form to create) and also in the HTML. You can
do this with any Component but keep in mind the more you customize them the
more work you'd have to do once you update your dependencies.

public class MyWizard extends Wizard {
    private static final long serialVersionUID = 1L;
    
    public MyWizard(String id) {
        super(id, false);
    }
    
    public MyWizard(String id, IWizardModel wizardModel) {
        super(id, wizardModel, false);
    }
    
    @Override
    public MyForm<?> getForm() {
        return (MyForm<?>)super.getForm();
    }
    
    @Override
    protected <E> MyForm<E> newForm(final String id) {
        MyForm<E> form = new MyForm<E>(id, true);
        form.setAuditUserInputOnFormSubmit(false);
        return form;
    }
    
    @Override
    protected FeedbackPanel newFeedbackPanel(String id) {
        FeedbackPanel feedbackPanel = new FeedbackPanel(id, new
ContainerFeedbackMessageFilter(this));
        feedbackPanel.setVisible(false);
        return feedbackPanel;
    }
    
    @Override
    protected Component newButtonBar(String id) {
        return new MyWizardButtonBar(id, this, finishOnAnyStep());
    }
    
    /**
     * On each step activation through the wizard, collect the user input
and the original default
     * values on the next step.
     * 
     * @see {@link Wizard#onActiveStepChanged(IWizardStep)}
     */
    @Override
    public void onActiveStepChanged(final IWizardStep newStep) {
        getForm().collectAfterFormInputComponents();
        super.onActiveStepChanged(newStep);
    }
    
    /**
     * Collect from components input for audit of changes since the form
submit is not always fired for
     * the Finish button. This happens when you directly edit a step and the
finish is enabled on every step.
     */
    @Override
    public void onFinish() {
        if(finishOnAnyStep()) {
            getForm().collectAfterFormInputComponents();
        }
    }
    
    /**
     * Override if you'd like the Finish button to be enabled on any step of
the wizard.
     * @return  <code>false</code> by default representing that the Finish
is only enabled at the last step.<br>
     *          <code>true</code> otherwise and the Finish button will
always be enabled.
     */
    protected boolean finishOnAnyStep() {
        return false;
    }
}

And in the HTML:
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:panel>
        <form wicket:id="form">
            <table class="wicketExtensionsWizardOuterTable">
                <tr>
                    <td valign="top">
                        <span wicket:id="overview">[[Overview]]</span>
                    </td>
                    <td valign="top">
                        <table class="wicketExtensionsWizardInnerTable">
                            <tr class="wicketExtensionsWizardHeaderRow">
                                <td valign="top"
class="wicketExtensionsWizardHeader"><span
wicket:id="header">[[Header]]</span></td>
                            </tr>
                            <tr class="wicketExtensionsWizardViewRow">
                                <td valign="top"
class="wicketExtensionsWizardView"><div wicket:id="view"
class="wicketExtensionsWizardViewInner">[[View]]</div></td>
                            </tr>
                            <tr class="wicketExtensionsWizardFeedbackRow">
                                <td valign="top"
class="wicketExtensionsWizardFeedback"><span
wicket:id="feedback">[[Feeback]]</span></td>
                            </tr>
                            <tr class="wicketExtensionsWizardButtonBarRow">
                                <td valign="top"
class="wicketExtensionsWizardButtonBar"><span
wicket:id="buttons">[[Buttons]]</span></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </form>
    </wicket:panel>
</html>


This is a simple example of how I use a wizard step to add a panel:


public class EditUserGroupPage extends Page {
    private static final long serialVersionUID = 1L;
    
    @SpringBean private UserGroupService    userGroupService;
    @SpringBean private UserService         userService;
    
    public static enum WizStep {
        /** Step 1 of 4 */ GROUP_DETAILS(1),
        /** Step 2 of 4 */ SET_PERMISSIONS(2),
        /** Step 3 of 4 */ SET_USERS(3),
        /** Step 4 of 4 */ VIEW_GROUP(4);
        
        private int stepNum;
        
        WizStep(int stepNum) {
            this.stepNum = stepNum;
        }
        
        public int getNum() {
            return this.stepNum;
        }
    }
    
    private CompoundPropertyModel<UserGroup> userGroupModel;
    
    public EditUserGroupPage() {
        this(ManageUserGroupsPage.class, new UserGroup(),
WizStep.GROUP_DETAILS);
    }
    
    public EditUserGroupPage(Class<? extends Page> backPage, UserGroup
editGroup, WizStep wizardStartStep) {
        for(Permission permission : editGroup.getPermissions()) {
            permission.setSelected(Boolean.TRUE);
        }
        this.backPage = backPage;
        this.userGroupModel = new
CompoundPropertyModel<UserGroup>(editGroup);
        
        ResourceModel pageTitleModel = new ResourceModel(
            (editGroup.getId() == null) ? "new.group" :
getPageClass().getName() + ResourceKeyHelper.PAGETITLE
        );
        add(new Label("pageTitle", pageTitleModel));
        add(new EditUserGroupWizard("wizard", wizardStartStep));
    }
    
    ...
    
    private class SetUsersStep extends WizardStep {
        private static final long serialVersionUID = 1L;
        public SetUsersStep() {
            Form<?> form = findParent(Form.class);
            add(new EditGroupMembersPanel("editGroupMembers", form));
        }
    }
    
    ...
}

EditUserGroupPage.html
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:extend>
        <table width=100% cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td class="dashboardTitle"><span wicket:id="pageTitle">[Edit
Group]</span></td>
            </tr>
            <tr><td class="table-divider"></td></tr>
            <tr>
                <td>
                    <span wicket:id="wizard">[[Wizard will be placed
here]]</span>
                </td>
            </tr>
        </table>
    </wicket:extend>
</html>

EditUserGroupPage#SetUsersStep.html
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:panel>
        <span wicket:id="editGroupMembers">[Users Palette]</span>
    </wicket:panel>
</html>

~ Thank you,
  Paul Bors


-----Original Message-----
From: shimin_q [mailto:smqian@hotmail.com] 
Sent: Wednesday, July 31, 2013 4:43 PM
To: users@wicket.apache.org
Subject: Re: How to add line breaks in the summary text of Wizard properties
file

Thanks for the suggestion!  Yes, I am extending WizardStep.  Here is what I
did to my code following your suggestion (the Header class is a final class,
so I had to create a new MultiLineHeader class extends Panel directly to add
new MultiLineLabel instead of the default new Label line in Header class. 
But I am getting error:

2013-07-31 16:35:45,813 [5245418@qtp-15847288-0] ERROR
org.apache.wicket.DefaultExceptionMapper  - Unexpected error occurred
org.apache.wicket.markup.MarkupNotFoundException: Failed to find markup file
associated. MultiLineHeader: [MultiLineHeader [Component id = header]]
	at
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMark
up(AssociatedMarkupSourcingStrategy.java:97)
	at
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:447)

Here is the code I put in:

    private final class OXEDetailsStep extends WizardStep implements
ICondition
    {
    	private static final long serialVersionUID = 1L;
        /**
         * Construct.
         */
        public OXEDetailsStep()
        {
              ...
         }

    	public Component getHeader(final String id, final Component parent,
final IWizard wizard)
    	{
    		return new MultiLineHeader(id, wizard);
    	}
    	
    	
    	private final class MultiLineHeader extends Panel
    	{
    		private static final long serialVersionUID = 1L;

    		/**
    		 * Construct.
    		 * 
    		 * @param id
    		 *            The component id
    		 * @param wizard
    		 *            The containing wizard
    		 */
    		public MultiLineHeader(final String id, final IWizard
wizard)
    		{
    			super(id);
    			setDefaultModel(new
CompoundPropertyModel<IWizard>(wizard));
    			add(new MultiLineLabel("title", new
AbstractReadOnlyModel<String>()
    			{
    				private static final long serialVersionUID =
1L;

    				@Override
    				public String getObject()
    				{
    					return getTitle();
    				}
    			}));
    			add(new MultiLineLabel("summary", new
AbstractReadOnlyModel<String>()
    			{
    				private static final long serialVersionUID =
1L;

    				@Override
    				public String getObject()
    				{
    					return getSummary();
    				}
    			}));
    		}
    	}
        
    }

Any ideas about the error?

Thanks so much for your help!






--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-sum
mary-text-of-Wizard-properties-file-tp4660589p4660595.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



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


Re: How to add line breaks in the summary text of Wizard properties file

Posted by dpmihai <dp...@yahoo.com>.
Thanks.

I did the following:

@Override
public Component getHeader(final String id, final Component parent, final
IWizard wizard) {
    		Component c = super.getHeader(id, parent, wizard);
    		c.get("summary").setEscapeModelStrings(false);
    		return c;
}

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-summary-text-of-Wizard-properties-file-tp4660589p4664241.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


Re: How to add line breaks in the summary text of Wizard properties file

Posted by Sven Meier <sv...@meiers.net>.
See https://issues.apache.org/jira/browse/WICKET-4219

Sven

On 02/06/2014 12:51 PM, dpmihai wrote:
> In Wicket 5 it was as easy as using <br> tags inside summary String.
>
> In Wicket 6 this simple way does not work anymore. Why?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-summary-text-of-Wizard-properties-file-tp4660589p4664234.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
>


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


RE: How to add line breaks in the summary text of Wizard properties file

Posted by dpmihai <dp...@yahoo.com>.
In Wicket 5 it was as easy as using <br> tags inside summary String.

In Wicket 6 this simple way does not work anymore. Why?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-summary-text-of-Wizard-properties-file-tp4660589p4664234.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


RE: How to add line breaks in the summary text of Wizard properties file

Posted by shimin_q <sm...@hotmail.com>.
Thanks Paul!  For now, creating a MultiLineHeader class to replace Header
class, as Sven suggested, did the trick.  But I will keep your point in mind
for any future customization of the default Wizard.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-summary-text-of-Wizard-properties-file-tp4660589p4660626.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


RE: How to add line breaks in the summary text of Wizard properties file

Posted by Paul Bors <pa...@bors.ws>.
So in your case I would just change my CSS and add a
wicketExtensionsWizardHeader with the width you want :)

~ Thank you,
  Paul Bors

-----Original Message-----
From: Paul Bors [mailto:paul@bors.ws] 
Sent: Wednesday, July 31, 2013 6:34 PM
To: users@wicket.apache.org
Subject: RE: How to add line breaks in the summary text of Wizard properties
file

The way I styled the wizard to fit my look-n-feel is by extending Wizard and
creating MyOwnWizard and then overriding whatever I wanted to change in the
Java code (such as the type of form to create) and also in the HTML. You can
do this with any Component but keep in mind the more you customize them the
more work you'd have to do once you update your dependencies.

public class MyWizard extends Wizard {
    private static final long serialVersionUID = 1L;
    
    public MyWizard(String id) {
        super(id, false);
    }
    
    public MyWizard(String id, IWizardModel wizardModel) {
        super(id, wizardModel, false);
    }
    
    @Override
    public MyForm<?> getForm() {
        return (MyForm<?>)super.getForm();
    }
    
    @Override
    protected <E> MyForm<E> newForm(final String id) {
        MyForm<E> form = new MyForm<E>(id, true);
        form.setAuditUserInputOnFormSubmit(false);
        return form;
    }
    
    @Override
    protected FeedbackPanel newFeedbackPanel(String id) {
        FeedbackPanel feedbackPanel = new FeedbackPanel(id, new
ContainerFeedbackMessageFilter(this));
        feedbackPanel.setVisible(false);
        return feedbackPanel;
    }
    
    @Override
    protected Component newButtonBar(String id) {
        return new MyWizardButtonBar(id, this, finishOnAnyStep());
    }
    
    /**
     * On each step activation through the wizard, collect the user input
and the original default
     * values on the next step.
     * 
     * @see {@link Wizard#onActiveStepChanged(IWizardStep)}
     */
    @Override
    public void onActiveStepChanged(final IWizardStep newStep) {
        getForm().collectAfterFormInputComponents();
        super.onActiveStepChanged(newStep);
    }
    
    /**
     * Collect from components input for audit of changes since the form
submit is not always fired for
     * the Finish button. This happens when you directly edit a step and the
finish is enabled on every step.
     */
    @Override
    public void onFinish() {
        if(finishOnAnyStep()) {
            getForm().collectAfterFormInputComponents();
        }
    }
    
    /**
     * Override if you'd like the Finish button to be enabled on any step of
the wizard.
     * @return  <code>false</code> by default representing that the Finish
is only enabled at the last step.<br>
     *          <code>true</code> otherwise and the Finish button will
always be enabled.
     */
    protected boolean finishOnAnyStep() {
        return false;
    }
}

And in the HTML:
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:panel>
        <form wicket:id="form">
            <table class="wicketExtensionsWizardOuterTable">
                <tr>
                    <td valign="top">
                        <span wicket:id="overview">[[Overview]]</span>
                    </td>
                    <td valign="top">
                        <table class="wicketExtensionsWizardInnerTable">
                            <tr class="wicketExtensionsWizardHeaderRow">
                                <td valign="top"
class="wicketExtensionsWizardHeader"><span
wicket:id="header">[[Header]]</span></td>
                            </tr>
                            <tr class="wicketExtensionsWizardViewRow">
                                <td valign="top"
class="wicketExtensionsWizardView"><div wicket:id="view"
class="wicketExtensionsWizardViewInner">[[View]]</div></td>
                            </tr>
                            <tr class="wicketExtensionsWizardFeedbackRow">
                                <td valign="top"
class="wicketExtensionsWizardFeedback"><span
wicket:id="feedback">[[Feeback]]</span></td>
                            </tr>
                            <tr class="wicketExtensionsWizardButtonBarRow">
                                <td valign="top"
class="wicketExtensionsWizardButtonBar"><span
wicket:id="buttons">[[Buttons]]</span></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </form>
    </wicket:panel>
</html>


This is a simple example of how I use a wizard step to add a panel:


public class EditUserGroupPage extends Page {
    private static final long serialVersionUID = 1L;
    
    @SpringBean private UserGroupService    userGroupService;
    @SpringBean private UserService         userService;
    
    public static enum WizStep {
        /** Step 1 of 4 */ GROUP_DETAILS(1),
        /** Step 2 of 4 */ SET_PERMISSIONS(2),
        /** Step 3 of 4 */ SET_USERS(3),
        /** Step 4 of 4 */ VIEW_GROUP(4);
        
        private int stepNum;
        
        WizStep(int stepNum) {
            this.stepNum = stepNum;
        }
        
        public int getNum() {
            return this.stepNum;
        }
    }
    
    private CompoundPropertyModel<UserGroup> userGroupModel;
    
    public EditUserGroupPage() {
        this(ManageUserGroupsPage.class, new UserGroup(),
WizStep.GROUP_DETAILS);
    }
    
    public EditUserGroupPage(Class<? extends Page> backPage, UserGroup
editGroup, WizStep wizardStartStep) {
        for(Permission permission : editGroup.getPermissions()) {
            permission.setSelected(Boolean.TRUE);
        }
        this.backPage = backPage;
        this.userGroupModel = new
CompoundPropertyModel<UserGroup>(editGroup);
        
        ResourceModel pageTitleModel = new ResourceModel(
            (editGroup.getId() == null) ? "new.group" :
getPageClass().getName() + ResourceKeyHelper.PAGETITLE
        );
        add(new Label("pageTitle", pageTitleModel));
        add(new EditUserGroupWizard("wizard", wizardStartStep));
    }
    
    ...
    
    private class SetUsersStep extends WizardStep {
        private static final long serialVersionUID = 1L;
        public SetUsersStep() {
            Form<?> form = findParent(Form.class);
            add(new EditGroupMembersPanel("editGroupMembers", form));
        }
    }
    
    ...
}

EditUserGroupPage.html
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:extend>
        <table width=100% cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td class="dashboardTitle"><span wicket:id="pageTitle">[Edit
Group]</span></td>
            </tr>
            <tr><td class="table-divider"></td></tr>
            <tr>
                <td>
                    <span wicket:id="wizard">[[Wizard will be placed
here]]</span>
                </td>
            </tr>
        </table>
    </wicket:extend>
</html>

EditUserGroupPage#SetUsersStep.html
<html xmlns:wicket="http://wicket.apache.org">
    <wicket:panel>
        <span wicket:id="editGroupMembers">[Users Palette]</span>
    </wicket:panel>
</html>

~ Thank you,
  Paul Bors


-----Original Message-----
From: shimin_q [mailto:smqian@hotmail.com]
Sent: Wednesday, July 31, 2013 4:43 PM
To: users@wicket.apache.org
Subject: Re: How to add line breaks in the summary text of Wizard properties
file

Thanks for the suggestion!  Yes, I am extending WizardStep.  Here is what I
did to my code following your suggestion (the Header class is a final class,
so I had to create a new MultiLineHeader class extends Panel directly to add
new MultiLineLabel instead of the default new Label line in Header class. 
But I am getting error:

2013-07-31 16:35:45,813 [5245418@qtp-15847288-0] ERROR
org.apache.wicket.DefaultExceptionMapper  - Unexpected error occurred
org.apache.wicket.markup.MarkupNotFoundException: Failed to find markup file
associated. MultiLineHeader: [MultiLineHeader [Component id = header]]
	at
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMark
up(AssociatedMarkupSourcingStrategy.java:97)
	at
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:447)

Here is the code I put in:

    private final class OXEDetailsStep extends WizardStep implements
ICondition
    {
    	private static final long serialVersionUID = 1L;
        /**
         * Construct.
         */
        public OXEDetailsStep()
        {
              ...
         }

    	public Component getHeader(final String id, final Component parent,
final IWizard wizard)
    	{
    		return new MultiLineHeader(id, wizard);
    	}
    	
    	
    	private final class MultiLineHeader extends Panel
    	{
    		private static final long serialVersionUID = 1L;

    		/**
    		 * Construct.
    		 * 
    		 * @param id
    		 *            The component id
    		 * @param wizard
    		 *            The containing wizard
    		 */
    		public MultiLineHeader(final String id, final IWizard
wizard)
    		{
    			super(id);
    			setDefaultModel(new
CompoundPropertyModel<IWizard>(wizard));
    			add(new MultiLineLabel("title", new
AbstractReadOnlyModel<String>()
    			{
    				private static final long serialVersionUID =
1L;

    				@Override
    				public String getObject()
    				{
    					return getTitle();
    				}
    			}));
    			add(new MultiLineLabel("summary", new
AbstractReadOnlyModel<String>()
    			{
    				private static final long serialVersionUID =
1L;

    				@Override
    				public String getObject()
    				{
    					return getSummary();
    				}
    			}));
    		}
    	}
        
    }

Any ideas about the error?

Thanks so much for your help!






--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/How-to-add-line-breaks-in-the-sum
mary-text-of-Wizard-properties-file-tp4660589p4660595.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




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