yes, but it won't be "generic".
btw, i ended up not using the previous scenario. instead, i directly "pass"
hql from view to db.
ugly hack but works like charm.
here's some snippets, hql AND criteria:
public class BaseListController implements Controller {
..properties, setters..
public ModelAndView handleRequest(...) {
List list;
if (!StringUtils.isBlank(request.getParameter("ql"))) {
list = baseManager.getByQl(targetClass,
request.getParameter("ql"));
} else {
Object o = targetClass.newInstance();
BeanUtils.populate(o, request.getParameterMap());
list = baseManager.getList(o);
}
return new ModelAndView(viewName, listName, list);
}
}
and in dao, i use:
public class BaseDaoHibernate extends HibernateDaoSupport implements BaseDao
{
public List getByQl(final Class c, final String ql) {
return getHibernateTemplate().find("from " + c.getName() + " where "
+ ql);
}
public List getList(final Object criteria) {
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session) throws
HibernateException {
Example ex =
Example.create(criteria).ignoreCase().enableLike(MatchMode.ANYWHERE);
return
session.createCriteria(criteria.getClass()).add(ex).list();
}
};
return (List)getHibernateTemplate().execute(callback);
}
}
these workaround resulted in that i don't have to create any
*Controller.java, instead in servlet.xml:
<bean id="fooController" class="...BaseListController">
<property name="baseManager" ref="baseManager"/>
<property name="targetClass" value="..Foo"/>
<property name="viewName" value="fooList"/>
<property name="listName">
<bean id="..Constants.FOO_LIST"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
</property>
</bean>
(i still use spring 1.2.x)
of course, if you look at the xml, we can do much better (like
"convention-ing" the wiring).
is there any known security issue by using this method?
i mean, can stuff like SQL-injection happen here?
mraible wrote:
>
> If you manually set the supplier name using
> targetBean.getSupplier().setName(request.parameter("supplier.name")) -
> does it work?
>
> Matt
>
> On 4/9/07, wiradikusuma <[EMAIL PROTECTED]> wrote:
>>
>> hi,
>> i need to filter displaytag using criteria. so i created a criteria form:
>> ========================================
>> <form method="get" id="specifierForm">
>> <input type="text" name="supplier.name"
>> value="${param['supplier.name']}"/>
>> <input type="submit" value="OK"/>
>> </form>
>> ========================================
>>
>>
>> leveraging appfuse's *Controller for displaying lists:
>> ========================================
>> public ModelAndView handleRequest(...)
>> ...
>> BeanUtils.populate(targetBean, request.getParameterMap());
>> ...
>> ========================================
>>
>>
>> my displaytag has:
>> ========================================
>> <display:column property="supplier.name"/>
>> ========================================
>>
>>
>> the thing is, BeanUtils.populate seems only do "shallow" populate. that
>> is,
>> it doesn't correctly handle request such as:
>> supplier.name (see my criteria form).
>>
>> is there any workaround for this?
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-filter-displaytag-tf3546089s2369.html#a9899108
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> http://raibledesigns.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/how-to-filter-displaytag-tf3546089s2369.html#a9901089
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]