- This topic has 3 replies, 3 voices, and was last updated 17 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
Gabriel Khoa BuiMemberIm developing a project under DWR Ajax and Hibernate. As a newbie, I followed every step of tutorial. I did the CREATE,INSERT,UPDATE,DELETE but needed data view. When running roles.jsp, an error has happned: “Object required” and view no data. I tried it lots and had no solutions.
Here is my following code:dwr.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd"> <dwr> <allow> <create javascript="RolesDAO" creator="new" scope="script"> <param name="class" value="com.huesoft.hibernate.RolesBean"/> </create> <convert match="com.huesoft.mapping.Roles" converter="bean" javascript="Roles"/> </allow> </dwr>
Roles.hbm.xml
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> <hibernate-mapping> <class name="com.huesoft.mapping.Roles" table="roles" catalog="ecity"> <id name="roleid" type="java.lang.Integer"> <column name="roleid" /> <generator class="increment" /> </id> <property name="rolename" type="java.lang.String"> <column name="rolename" length="50" not-null="true" /> </property> <property name="description" type="java.lang.String"> <column name="description" length="1000" not-null="true" /> </property> <property name="status" type="java.lang.Byte"> <column name="status" /> </property> <set name="columnses" inverse="true"> <key> <column name="roleid" /> </key> <one-to-many class="com.huesoft.mapping.Columns" /> </set> <set name="userses" inverse="true"> <key> <column name="roleid" not-null="true" /> </key> <one-to-many class="com.huesoft.mapping.Users" /> </set> </class> </hibernate-mapping>
[u]UserBeam.java[/u]
/** * RolesBean.java */ ............... public static List<Roles> getAllRoles() throws HibernateException{ List<Roles> list = new ArrayList<Roles>(); Session session = null; try{ session = HibernateUtil.currentSession(); session.beginTransaction(); Query q = session.createQuery("from Roles r"); list = q.list(); }finally{ try{ session.close(); }catch (Exception e) { if(logger.isDebugEnabled()) logger.error("Error: "+e); session.getTransaction().rollback(); } } return (list); } }
……………………………………..
checkRoles.js
var rolesCache = {}; function init_roles(){ fillObjectRoles(); } function fillObjectRoles(){ dwr.util.removeAllRows("viewRoles"); RolesDAO.getAllRoles(function(roles){ for(i =0;i<roles.length;i++){ dwr.util.cloneNode("patternRoles",{idSuffix:roles[i].roleid}); dwr.util.setValue("rolename"+roles[i].roleid, roles[i].rolename); dwr.util.setValue("description"+roles[i].roleId, roles[i].description); dwr.util.setValue("status"+roles[i].roleid, roles[i].status); $("patternRoles"+roles[i].roleid).style.display=''; rolesCache[roles[i]] = roles[i]; } });
roles.jsp<tbody id="viewRoles"> <tr id="patternRoles" style="display:none;"> <!-- <td width="10%" align="center"> <input type=checkbox id="checkboxname"> </td> <td width="30%"><span id="rolename">rolename</span></td> <td width="30%"><span id="description">description</span></td> --> <td width="30%"><span id="status">status</span></td> </tr> </tbody>
Thanks and Best regards, Khoa.
Loyal WaterMemberWhat tutorial are you following ?
Gabriel Khoa BuiMemberOf my collegue. I made a litle change. All of us tried with error. I removed this fragile:
<set name=”columnses” inverse=”true”>
<key>
<column name=”roleid” />
</key>
<one-to-many class=”com.huesoft.mapping.Columns” />
</set>
<set name=”userses” inverse=”true”>
<key>
<column name=”roleid” not-null=”true” />
</key>
<one-to-many class=”com.huesoft.mapping.Users” />
</set>
It was okie. Hence, what fun, I could not use with Hibernate any more. I think the main point is in *.hbm.xml. Any ideas??Thanx, Khoa
Riyad KallaMemberMoving to OT > Soft Dev
-
AuthorPosts