jquery - onchange function using spring roo distribution (gvnix) -
i new spring roo( using gvnix spring roo distribution jquery, bootstrap , databale). have created 3 tables in mysql
create table `categories` ( `id` int(11) not null auto_increment, `category_name` varchar(50) not null, `description` varchar(50) not null, primary key (`id`) ) engine=innodb auto_increment=4 default charset=utf8; insert `categories`(`id`,`category_name`,`description`) values (1,'facility','facility'),(2,'ikare','ikare'); create table `subcategories` ( `id` int(11) not null auto_increment, `subcategory_name` varchar(50) not null, `category_id` int(11) not null, primary key (`id`), key `fk_md1atoxe8wd8bi2fhf9nnw4q0` (`category_id`), constraint `fk_md1atoxe8wd8bi2fhf9nnw4q0` foreign key (`category_id`) references `categories` (`id`) ) engine=innodb auto_increment=5 default charset=utf8; insert `subcategories`(`id`,`subcategory_name`,`category_id`) values (1,'room service',1),(2,'store',1),(3,'server setup',2),(4,'travel not working',2);
and used database reverse engineering command create bean file.
and used scaffold,jquery,bootstrap , dattable
now after deploying app tomcat7 able create categories, subcategories.
my problem while creating new service desk, category showing in dropdown , sub category showing in default. want when select specific category should display respective subcategory not subcategory category.
and validation not working means if don't enter in mandatory field able save data.
below code create new service.
<?xml version="1.0" encoding="utf-8" standalone="no"?> <div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/web-inf/tags/jquery/form/fields" xmlns:form="urn:jsptagdir:/web-inf/tags/datatables" xmlns:jsp="http://java.sun.com/jsp/page" xmlns:spring="http://www.springframework.org/tags" version="2.0"> <jsp:directive.page contenttype="text/html;charset=utf-8"/> <jsp:output omit-xml-declaration="yes"/> <form:create id="fc_com_arat_roo_domain_servicedesk" modelattribute="servicedesk" path="/servicedesks" render="${empty dependencies}" z="5ry4njcp8nj/t0txbzs8xzlebzs="> <field:select field="categoryid" id="c_com_arat_roo_domain_servicedesk_categoryid" itemvalue="id" items="${categorieses}" path="/categorieses" z="etrza7tdsb6iogaa143b/eeczgs="/> <field:select field="subcategoryid" id="c_com_arat_roo_domain_servicedesk_subcategoryid" itemvalue="id" items="${subcategorieses}" path="/subcategorieses" z="wloz5ug2o8vxzdxyu7gg1q0zx9w="/> <field:input field="comment" id="c_com_arat_roo_domain_servicedesk_comment" required="true" z="h/4ghqswuy162ci8qehagmy7zuy="/> </form:create> <form:dependency dependencies="${dependencies}" id="d_com_arat_roo_domain_servicedesk" render="${not empty dependencies}" z="zpbtjtne7e7oxm/3c5dw9bagnsm="/> </div>
and controller below:
@requestmapping(params = "form", produces = "text/html") public string createform(model uimodel) { populateeditform(uimodel, new servicedesk()); return "servicedesks/create"; } void populateeditform(model uimodel, servicedesk servicedesk) { uimodel.addattribute("servicedesk", servicedesk); uimodel.addattribute("categorieses", categories.findallcategorieses()); uimodel.addattribute("subcategorieses", subcategories.findallsubcategorieses()); }
and below log.roo command used.
// spring roo 1.3.1.release [rev 8cb81a3] log opened @ 2016-02-06 00:33:13 project --toplevelpackage com.arat.roo --projectname ssd --java 6 --packaging war // spring roo 1.3.1.release [rev 8cb81a3] log closed @ 2016-02-06 00:33:15 // spring roo 1.3.1.release [rev 8cb81a3] log opened @ 2016-02-06 00:34:16 osgi start --url file:///c:/users/arat/.m2/repository/mysql/mysql-connector-java/5.1.20/mysql-connector-java-5.1.20.jar hint persistence setup --database mysql --provider hibernate --databasename learning --username root --password gayathri/?@123 osgi start --url file:///c:/users/arat/.m2/repository/mysql/mysql-connector-java/5.1.20/mysql-connector-java-5.1.20.jar database introspect --schema no-schema-required database reverse engineer --schema root --package ~.domain --includetables "categories subcategories service_desk" web mvc setup web mvc --package ~.web web mvc jquery setup web mvc jquery web mvc datatables setup web mvc bootstrap setup web mvc bootstrap update web mvc datatables jpa gvnix setup jpa batch web mvc batch setup web mvc batch web mvc datatables detail add --type ~.web.categoriescontroller --property subcategorieses web mvc datatables detail add --type ~.web.servicedeskcontroller --property subcategorieses web mvc datatables detail add --type ~.web.servicedeskcontroller --property categorieses
could please me on this?
take loupe field component. can show datatable allow select subcategories filtering categories.
good luck!
Comments
Post a Comment