You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Mathias P.W Nilsson" <ma...@snyltarna.se> on 2008/04/04 17:30:56 UTC
Multiple TextField in ListView
Hi!
In my application a user should be able to connect keywords to a datasheet.
When clicking the link add keywords 10-20 textfields should appear and the
user can enter data to
the fields.
#1
textField
#2
textfield
......
How can I handle this like an array in wicket? I do not want to add 20
textfields by hand.
--
View this message in context: http://www.nabble.com/Multiple-TextField-in-ListView-tp16492002p16492002.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: Multiple TextField in ListView
Posted by "Mathias P.W Nilsson" <ma...@snyltarna.se>.
Thanks!
I will try this immediately!
--
View this message in context: http://www.nabble.com/Multiple-TextField-in-ListView-tp16492002p16510457.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: Multiple TextField in ListView
Posted by jeredm <je...@maplewoodsoftware.com>.
Here is how I would do it:
HTML:
<table>
<tr wicket:id="tableRow">
<td>
. <input wicket:id="textInput" type="text" />
</td>
</tr>
</table>
Model Object:
// this is a simple object I am going to use for my model.
// It holds the value the user will enter in the textbox and
// a primary key value, so I know how to update my database
// when I save.
private class RandomObject implements Serializable{
private static final long serialVersionUID = 1L;
private String textValue;
private int pkValue;
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public int getPkValue() {
return pkValue;
}
public void setPkValue(int pkValue) {
this.pkValue = pkValue;
}
private RandomObject(String textValue, int pkValue){
this.textValue = textValue;
this.pkValue = pkValue;
}
}
Java for the page layout:
// Create objects however...here I make 3
// Store the list somewhere so you can loop through it and save each
// key word on submit...I did not add the submit code here, but it is basic
enough
ArrayList<RandomObject> myArray = new ArrayList<RandomObject>();
myArray.add(new RandomObject(null, 1));
myArray.add(new RandomObject(null, 2));
myArray.add(new RandomObject(null, 3));
ListView theView = new ListView("tableRow", myArray){
private static final long serialVersionUID = 1L;
public void populateItem(final ListItem listItem){
final RandomObject item = (RandomObject)listItem.getModelObject();
listItem.add(new Label("numberLabel", new
Model(String.valueOf(listItem.getIndex() + 1))));
// Could add validation here if needed.
listItem.add(new TextField("textInput", new PropertyModel(item,
"textValue")));
}
};
add(theView);
Mathias P.W Nilsson wrote:
>
> Hi!
>
> In my application a user should be able to connect keywords to a
> datasheet.
>
> When clicking the link add keywords 10-20 textfields should appear and the
> user can enter data to
> the fields.
>
> #1
> textField
> #2
> textfield
> ......
>
>
> How can I handle this like an array in wicket? I do not want to add 20
> textfields by hand.
>
--
View this message in context: http://www.nabble.com/Multiple-TextField-in-ListView-tp16492002p16496226.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: Multiple TextField in ListView
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
A listview with a listview or a repeater?
Mathias P.W Nilsson wrote:
> Hi!
>
> In my application a user should be able to connect keywords to a datasheet.
>
> When clicking the link add keywords 10-20 textfields should appear and the
> user can enter data to
> the fields.
>
> #1
> textField
> #2
> textfield
> ......
>
>
> How can I handle this like an array in wicket? I do not want to add 20
> textfields by hand.
>
--
-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