1.

How To Create Dropdown Choice In Apache-wicket?

Answer»

//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>

//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>



Discussion

No Comment Found