Apache Wicket Interview Questions and Answers
Ques 16. How to create single selected ListBox?
// single list choice
private static final List<String> FRUITS = Arrays.asList(new String[] { "Apple", "Orange", "Banana" });
ListChoice<String> listFruits = new ListChoice<String>("fruit", new PropertyModel<String>(this, "selectedFruit"), FRUITS);
listFruits.setMaxRows(5);
Is it helpful?
Add Comment
View Comments
Ques 17. How to create multiple selected ListBox in apache-wicket?
//choices in list box
private static final List<String> NUMBERS = Arrays.asList(new String[] {"Number 1", "Number 2", "Number 3", "Number 4", "Number 5", "Number 6" });
//variable to hold the selected multiple values from listbox,
//and make "Number 6" selected as default value
private ArrayList<String> selectedNumber = new ArrayList<String>(
Arrays.asList(new String[] { "Number 6" }));
ListMultipleChoice<String> listNumbers = new ListMultipleChoice<String>(
"number", new Model(selectedNumber), NUMBERS);
//HTML for multiple select listbox
<select wicket:id="number"></select>
Is it helpful?
Add Comment
View Comments
Ques 18. How to create DropDown Choice in apache-wicket?
//Java
import org.apache.wicket.markup.html.form.DropDownChoice;
...
//choices in dropdown box
private static final List<String> SEARCH_ENGINES = Arrays.asList(new String[] {
"Google", "Bing", "Baidu" });
//variable to hold the selected value from dropdown box,
//and also make "Google" is selected by default
private String selected = "Google";
DropDownChoice<String> listSites = new DropDownChoice<String>(
"sites", new PropertyModel<String>(this, "selected"), SEARCH_ENGINES);
//HTML for dropdown box
<select wicket:id="sites"></select>
Is it helpful?
Add Comment
View Comments
Ques 19. How to create FileUpload field in apache-wicket?
//Java
import org.apache.wicket.markup.html.form.upload.FileUploadField;
form.setMultiPart(true);
form.add(fileUpload = new FileUploadField("fileUpload"));
//HTML
<input wicket:id="fileUpload" type="file"/>
Is it helpful?
Add Comment
View Comments
Ques 20. How to create Select Option as menu wise in apache-wicket?
//Java
import org.apache.wicket.extensions.markup.html.form.select.Select;
import org.apache.wicket.extensions.markup.html.form.select.SelectOption;
...
//variable to hold the selected value from dropdown box,
//and also make "jQuery" selected by default
private String selected = "jQuery";
Select languages = new Select("languages", new PropertyModel<String>(this, "selected"));
form.add(languages);
languages.add(new SelectOption<String>("framework1", new Model<String>("Wicket")));
languages.add(new SelectOption<String>("framework2", new Model<String>("Spring MVC")));
languages.add(new SelectOption<String>("framework3", new Model<String>("JSF 2.0")));
languages.add(new SelectOption<String>("Script1", new Model<String>("jQuery")));
languages.add(new SelectOption<String>("Script2", new Model<String>("prototype")));
//HTML for dropdown box
<select wicket:id="languages">
<optgroup label="Frameworks">
<option wicket:id="framework1" >Wicket (1.4.7)</option>
<option wicket:id="framework2" >Spring MVC (3.0)</option>
<option wicket:id="framework3" >JSF (2.0)</option>
</optgroup>
<optgroup label="JavaScript">
<option wicket:id="Script1" >jQuery (1.6.1)</option>
<option wicket:id="Script2" >prototype (1.7)</option>
</optgroup>
</select>
Is it helpful?
Add Comment
View Comments
Most helpful rated by users:
- What is Wicket Framework?
- What are Wicket Models?
- What is Base class for HTML pages?
- What are the Ways to create a page in wicket?
- How to integrate apache-wicket with Spring?