You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by m_salman <mo...@yahoo.com> on 2008/06/13 10:05:50 UTC

Panels in a panel

Hi,

I have designed a panel of form text fields which I would like to repeat in
a panel of form.

Here is the code:

EmptyForm.java

public class EmptyForm extends Form 
{
	private final ValueMap properties = new ValueMap();

	public EmptyForm(final String id)
	{
		super(id);
	}
	
	public void addFormComponent(
		FormComponent formComponent)
	{
		add(formComponent);
	}

	public ValueMap getValueMap()
	{
		return properties;
	}
	
	public final void onSubmit()
	{
		// some stuff
	}

}




EmptyFormPanel.java

public class EmptyFormPanel extends Panel
{
	private EmptyForm emptyForm;
	private ValueMap valueMap;

	/**
	 * @see org.apache.wicket.Component#Component(String)
	 */
	public EmptyFormPanel(final String id)
	{
		super(id);

		emptyForm = new EmptyForm("emptyForm");
		valueMap = emptyForm.getValueMap();		
		add(emptyForm);
		
		
		List<TextFieldBean> textFields = new ArrayList<TextFieldBean>();
		
		textFields.add(new TextFieldBean("User Name", "userName"));
		textFields.add(new TextFieldBean("Password", "password"));
		
		ListView formTextFieldPanels = new ListView( "formTextFieldPanels" ,
textFields)
		{
			protected void populateItem(ListItem item)
			{
				TextFieldBean textFieldBean = (TextFieldBean) item.getModelObject();
				
				FormTextFieldPanel formTextFieldPanel = new
FormTextFieldPanel("formTextFieldPanels");
				
				//item.add(formTextFieldPanel);
				formTextFieldPanel.addItem(emptyForm, item, textFieldBean, valueMap);
				//emptyForm.add(formTextFieldPanel);
				
			}
			
		};
		
		add(formTextFieldPanels);
		
		
	}
	
	public EmptyForm getEmptyForm()
	{
		return emptyForm;
	}
	
	public ValueMap getValueMap()
	{
		return valueMap;
	}
	
}


EmptyFormPanel.html

<html xmlns:wicket>
<body>
  <wicket:panel wicket:id="emptyFormPanels">
		<form wicket:id="emptyForm">
			<table>
				<div wicket:id="formTextFieldPanels"></div>
				<tr>
					<td></td>
					<td>
						<input type="submit" name="submit" value="Sign In"/>
						<input type="reset" value="Reset"/>
					</td>
				</tr>
			</table>
		</form>
  </wicket:panel>
</body>
</html>




FormTextFieldPanel.java

public class FormTextFieldPanel extends Panel 
{
	
	public FormTextFieldPanel(String id) 
	{
		super(id);
	}

	
	public void addItem(
		EmptyForm emptyForm,
		ListItem item,
		TextFieldBean textFieldBean,
		ValueMap valueMap)
	{
		item.add(new Label("fieldNameLabel", textFieldBean.getFieldName()));
		item.add(new TextField("fieldId", new PropertyModel(valueMap,
textFieldBean.getFieldId())));					
		//emptyForm.add(item);
	}
	
	
}


FormTextFieldPanel.html

<html xmlns:wicket>
<body>
  <wicket:panel id="formTextFieldPanels">
				<tr>
					<td align="right" wicket:id="fieldNameLabel">fieldName</td>
					<td>
						<input wicket:id="fieldId" type="text" value="foo@goo.moo" size="30"/>
					</td>
				</tr>
  </wicket:panel>
</body>
</html>


I would like "FormTextFieldPanel" to repeat inside "EmptyFormPanel"


My problem is with "formTextFieldPanels" component. 

If I use
 
    emptyForm.add(formTextFieldPanel);

then I get the error message that "formTextFieldPanels" is being repeated (
" a component by this name already exists")

If I don't use it then I get the error message that this component is
missing.


Can some one please tell me what will be the right way to handle this.
I tried to do search for this and it seems that there is a way of doing this
by using RepeaterView.
If so then please let me know how.


Thank you

-Mohammad
-- 
View this message in context: http://www.nabble.com/Panels-in-a-panel-tp17817534p17817534.html
Sent from the Wicket - User 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: Panels in a panel

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Or the wicket-iolite maven archetype, which has a really simple example 
of this:

http://wicketstuff.org/confluence/display/STUFFWIKI/Wicket-Iolite

James Carman wrote:
> On Fri, Jun 13, 2008 at 11:51 AM, m_salman <mo...@yahoo.com> wrote:
>
>   
>> Thanks for your reply.
>>
>> Unfortunately I need more information than that. Something like exactly what
>> and how to use, with code.
>> I have been trying to get this thing working for some days now and I really
>> need help with this.
>> My whole decision about moving my project to Wicket depends on this and I
>> really do wan tto use Wicket.
>>     
>
> Why don't you check out this example?
>
> http://wicket.apache.org/exampleguestbook.html
>
> That should give you all you need to get up and running.  I'd also
> suggest starting with a "quickstart" application and build from that
> (if you haven't already).
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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


Re: Panels in a panel

Posted by James Carman <ja...@carmanconsulting.com>.
On Fri, Jun 13, 2008 at 11:51 AM, m_salman <mo...@yahoo.com> wrote:

> Thanks for your reply.
>
> Unfortunately I need more information than that. Something like exactly what
> and how to use, with code.
> I have been trying to get this thing working for some days now and I really
> need help with this.
> My whole decision about moving my project to Wicket depends on this and I
> really do wan tto use Wicket.

Why don't you check out this example?

http://wicket.apache.org/exampleguestbook.html

That should give you all you need to get up and running.  I'd also
suggest starting with a "quickstart" application and build from that
(if you haven't already).

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


Re: Panels in a panel

Posted by m_salman <mo...@yahoo.com>.


Nino.Martinez wrote:
> 
> use a listview,propertylistview or repeater...
> 
> Differences are:
> 
> listview: iterates over a list
> propertylistviw:-||- and bound the item.model via a compound model, very 
> usefull if you use compound models a lot.
> repeater: repeats for int times, as I remember it..
> 
> 
> 


Thanks for your reply.

Unfortunately I need more information than that. Something like exactly what
and how to use, with code.
I have been trying to get this thing working for some days now and I really
need help with this.
My whole decision about moving my project to Wicket depends on this and I
really do wan tto use Wicket.

Thanks so much again.

-Mohammad
-- 
View this message in context: http://www.nabble.com/Panels-in-a-panel-tp17817534p17826539.html
Sent from the Wicket - User 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: Panels in a panel

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
use a listview,propertylistview or repeater...

Differences are:

listview: iterates over a list
propertylistviw:-||- and bound the item.model via a compound model, very 
usefull if you use compound models a lot.
repeater: repeats for int times, as I remember it..



m_salman wrote:
> Hi,
>
> I have designed a panel of form text fields which I would like to repeat in
> a panel of form.
>
> Here is the code:
>
> EmptyForm.java
>
> public class EmptyForm extends Form 
> {
> 	private final ValueMap properties = new ValueMap();
>
> 	public EmptyForm(final String id)
> 	{
> 		super(id);
> 	}
> 	
> 	public void addFormComponent(
> 		FormComponent formComponent)
> 	{
> 		add(formComponent);
> 	}
>
> 	public ValueMap getValueMap()
> 	{
> 		return properties;
> 	}
> 	
> 	public final void onSubmit()
> 	{
> 		// some stuff
> 	}
>
> }
>
>
>
>
> EmptyFormPanel.java
>
> public class EmptyFormPanel extends Panel
> {
> 	private EmptyForm emptyForm;
> 	private ValueMap valueMap;
>
> 	/**
> 	 * @see org.apache.wicket.Component#Component(String)
> 	 */
> 	public EmptyFormPanel(final String id)
> 	{
> 		super(id);
>
> 		emptyForm = new EmptyForm("emptyForm");
> 		valueMap = emptyForm.getValueMap();		
> 		add(emptyForm);
> 		
> 		
> 		List<TextFieldBean> textFields = new ArrayList<TextFieldBean>();
> 		
> 		textFields.add(new TextFieldBean("User Name", "userName"));
> 		textFields.add(new TextFieldBean("Password", "password"));
> 		
> 		ListView formTextFieldPanels = new ListView( "formTextFieldPanels" ,
> textFields)
> 		{
> 			protected void populateItem(ListItem item)
> 			{
> 				TextFieldBean textFieldBean = (TextFieldBean) item.getModelObject();
> 				
> 				FormTextFieldPanel formTextFieldPanel = new
> FormTextFieldPanel("formTextFieldPanels");
> 				
> 				//item.add(formTextFieldPanel);
> 				formTextFieldPanel.addItem(emptyForm, item, textFieldBean, valueMap);
> 				//emptyForm.add(formTextFieldPanel);
> 				
> 			}
> 			
> 		};
> 		
> 		add(formTextFieldPanels);
> 		
> 		
> 	}
> 	
> 	public EmptyForm getEmptyForm()
> 	{
> 		return emptyForm;
> 	}
> 	
> 	public ValueMap getValueMap()
> 	{
> 		return valueMap;
> 	}
> 	
> }
>
>
> EmptyFormPanel.html
>
> <html xmlns:wicket>
> <body>
>   <wicket:panel wicket:id="emptyFormPanels">
> 		<form wicket:id="emptyForm">
> 			<table>
> 				<div wicket:id="formTextFieldPanels"></div>
> 				<tr>
> 					<td></td>
> 					<td>
> 						<input type="submit" name="submit" value="Sign In"/>
> 						<input type="reset" value="Reset"/>
> 					</td>
> 				</tr>
> 			</table>
> 		</form>
>   </wicket:panel>
> </body>
> </html>
>
>
>
>
> FormTextFieldPanel.java
>
> public class FormTextFieldPanel extends Panel 
> {
> 	
> 	public FormTextFieldPanel(String id) 
> 	{
> 		super(id);
> 	}
>
> 	
> 	public void addItem(
> 		EmptyForm emptyForm,
> 		ListItem item,
> 		TextFieldBean textFieldBean,
> 		ValueMap valueMap)
> 	{
> 		item.add(new Label("fieldNameLabel", textFieldBean.getFieldName()));
> 		item.add(new TextField("fieldId", new PropertyModel(valueMap,
> textFieldBean.getFieldId())));					
> 		//emptyForm.add(item);
> 	}
> 	
> 	
> }
>
>
> FormTextFieldPanel.html
>
> <html xmlns:wicket>
> <body>
>   <wicket:panel id="formTextFieldPanels">
> 				<tr>
> 					<td align="right" wicket:id="fieldNameLabel">fieldName</td>
> 					<td>
> 						<input wicket:id="fieldId" type="text" value="foo@goo.moo" size="30"/>
> 					</td>
> 				</tr>
>   </wicket:panel>
> </body>
> </html>
>
>
> I would like "FormTextFieldPanel" to repeat inside "EmptyFormPanel"
>
>
> My problem is with "formTextFieldPanels" component. 
>
> If I use
>  
>     emptyForm.add(formTextFieldPanel);
>
> then I get the error message that "formTextFieldPanels" is being repeated (
> " a component by this name already exists")
>
> If I don't use it then I get the error message that this component is
> missing.
>
>
> Can some one please tell me what will be the right way to handle this.
> I tried to do search for this and it seems that there is a way of doing this
> by using RepeaterView.
> If so then please let me know how.
>
>
> Thank you
>
> -Mohammad
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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