0

使用基于 seam-gen 的代码。我有一个对象“教室”,其中包含一个“位置”实例。我想查询教室但在 Location 对象上指定一个值。

类似于“从 Location.State = "NY" 的课堂中选择”。当我尝试将带有状态列表的 selectOneMenu 绑定到 #{ClassroomList.classroom.location.state} 时,我遇到了错误。

在 Location 上收到空指针异常。我假设我需要在 Classroom 对象上实例化一个新的“位置”,但不知道在哪里做。在教室实体的构造函数上?在 ClassroomList 支持 bean 上(示例对象绑定到 ClassroomList JSP 搜索字段的位置)?

4

2 回答 2

0

Not sure if this is the best way, but I got it working.

I have a String exposed on my ClassroomList backing bean as "String locationState". My dropdown list of states binds to that

Then that's referenced in my restrictions as: ... lower(classroom.location.state) like lower(concat(#{classroomList.locationState}, '%'))", ...

--

When I tried to instantiate ClassroomList.instance.Location, I would get: javax.servlet.ServletException with message: "Id and clazz must not be null" Not sure what's causing that?

于 2012-05-16T13:44:45.063 回答
0

是的,您需要实例化 ClassroomList.instance.Location。因为 ClassroomList.instance 没有绑定到数据库,所以这不是自动完成的

于 2012-05-16T12:58:54.597 回答