Dynamic Drop Down Menu
Hi,
I want to create drop down menu , as i created succesfully but i want user to select on one drop down menu and depending on selected item from drop down menu one , drop down menu 2 items populated.
Current problem is:
suppose there are two category “Animals” and “Vehicles”, and Sub categories are “CAT”,“DOG”,“BUS”,“CAR” , so right now issue is whatever i select in category it will display all four sub categories but now i want show sub category depending on Category selection.
code snippet right now is:
@General(title = "XYZ Parser", purpose = "Parse XYZ file", author = "NeosAlpha", docLink = "http://neosalpha.com/")
@Outputs(min = 1, max = 1, offers = ViewType.DOCUMENT)
@Errors(min = 1, max = 1, offers = ViewType.DOCUMENT)
@Version(snap = 1)
@Category(snap = SnapCategory.PARSE)
public class XYZParser extends SimpleBinaryWriteSnap implements DependencyManager {
private static final String FILE_BROWSER_PROP = "file_browser_prop";
private static final String XYZ_TYPE_PROP = "XYZ_type_prop";
private static final String XYZ_TYPE_PROP_VALUE = "Animals";
private static final String FILE_TYPE_PROP = "file_type_prop";
private static final String FILE_TYPE_PROP_VALUE = "Vehicles";
private String filePath;
@Inject
private DocumentUtility documentUtility;
@Inject
private URLEncoder urlEncoder;
@Inject
private JfsUtils jfsUtils;
String fileBrowser;
String filetype;
String XYZtype;
Map<String, Object> composite;
@Override
public Module getManagedModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(ForEx.class).to(ForExImpl.class);
bind(JfsUtils.class).toInstance(JfsUtils.getInstance());
}
};
}
// An optional file selector for providing exchange rates within a file
@Override
public void defineProperties(PropertyBuilder propertyBuilder) {
Set<String> XYZ_set = new HashSet<String>();
XYZ_set.add("");
XYZ_set.add("Animals");
XYZ_set.add("Vehicles");
Set<String> file_set = new HashSet<String>();
file_set.add("");
file_set.add("CAT");
file_set.add("CAR");
file_set.add("DOG");
file_set.add("BUS");
propertyBuilder.describe(XYZ_TYPE_PROP, "XYZ Type",
"Write XYZ ")
.withAllowedValues(XYZ_set)
.required()
.add();
propertyBuilder.describe(FILE_TYPE_PROP, "File Type",
"Write File type ")
.withAllowedValues(file_set)
.required()
.add();
}
@Override
public void configure(PropertyValues propertyValues) throws ConfigurationException {
filetype = propertyValues.getAsExpression(FILE_TYPE_PROP).eval(null);
XYZtype = propertyValues.getAsExpression(XYZ_TYPE_PROP).eval(null);
}
@Override
public void cleanup() throws ExecutionException {
// TODO Auto-generated method stub
}
@Override
protected void process(final Document document, final ReadableByteChannel readChannel) {
try (InputStream inputStream = Channels.newInputStream(readChannel)) {
if(filetype.contentEquals("Animals") && XYZtype.contentEquals("CAT"))
{
} else {
// PUT ERROR CODE HERE
}
}
else if(filetype.contentEquals("Vehicles") && XYZtype.contentEquals("BUS") )
{
}
else {
// Error Code Here
}
} catch (IOException e) {
errorViews.write(new SnapDataException(e, e.getMessage()), document);
} finally {
}
outputViews.write(documentUtility.newDocument(data),document);
}
}
What i want is given below:
For example firstly i select category which are “Animals” or “Vehicles”.
Suppose if i select Animals from category dropdown menu then in next dropdown only selections are shown is “CAT” or “DOG”
Suppose if i select Vehicles from category drop down menu then in next drop down only selections are shown is “BUS” or “CAR”
Just give me code snippet i ll do the rest.
Thanks
Nikhil Purohit