-
1. Re: Problem with OneSelectMenu and entity selection
amitdk Feb 25, 2008 5:51 AM (in response to amitdk)Still no luck with this. I have pretty much done exactly the same thing as documented here -
SeamEntityConverterOnly change I see here is in selectItems, instead of just value="#{objectiveTaskList}", I changed it to value="#{objectiveTaskList.resultList}". However instead of declaring the select item list component in the components.xml, I am using the generated annotated ObjectiveTaskList.
Please any help with this would be appreciated. Since the article also seems to point that what I am doing is legit, I really would like someone to point out what I am missing.
Thanks
Amit -
2. Re: Problem with OneSelectMenu and entity selection
luxspes Feb 25, 2008 7:30 AM (in response to amitdk)Hi!
How do you know it is not working?
It just silently fails?
It throws an exception?Are modifing one of the seam-gen CRUD editor pages? or is it a page created from scratch by you? how do you know that the problem is the OneSelectMenu and not the code you use to persist your POJO?
Regards
LuxSpes -
3. Re: Problem with OneSelectMenu and entity selection
damianharvey.damianharvey.gmail.com Feb 25, 2008 10:25 AM (in response to amitdk)Show your code for ObjectiveTaskList. Is the list a list of SelectItems (if so you should use f:selectItems) or a list of entities?
Cheers,
Damian.
-
4. Re: Problem with OneSelectMenu and entity selection
nickarls Feb 25, 2008 10:38 AM (in response to amitdk)Place a h:messages tag on the page and see if you get any
value not in list
-errors. If so, override hashCode() and equals() on the entity... -
5. Re: Problem with OneSelectMenu and entity selection
amitdk Feb 25, 2008 5:08 PM (in response to amitdk)Thanks for all the responses. Here's more information as requested.
I am not using the seam-gen CRUD page for this. However the domain objects are seam-gen generated. Here's what ObjectiveTaskList looks like:
@Name("objectiveTaskList") public class ObjectiveTaskList extends EntityQuery { private static final String[] RESTRICTIONS = {"lower(objectiveTask.description) like concat(lower(#{objectiveTaskList.objectiveTask.description}),'%')",}; private ObjectiveTask objectiveTask = new ObjectiveTask(); @Override public String getEjbql() { return "select objectiveTask from ObjectiveTask objectiveTask"; } @Override public Integer getMaxResults() { return 25; } public ObjectiveTask getObjectiveTask() { return objectiveTask; } @Override public List<String> getRestrictions() { return Arrays.asList(RESTRICTIONS); } }
And here's the TaskAssignmentHome that was generated:
@Name("taskAssignmentHome") public class TaskAssignmentHome extends EntityHome<TaskAssignment> { @In(create = true) ObjectiveTaskHome objectiveTaskHome; @In(create = true) AssociateHome associateHome; public void setTaskAssignmentId(Integer id) { setId(id); } public Integer getTaskAssignmentId() { return (Integer) getId(); } @Override protected TaskAssignment createInstance() { TaskAssignment taskAssignment = new TaskAssignment(); return taskAssignment; } public void wire() { ObjectiveTask objectiveTask = objectiveTaskHome.getDefinedInstance(); if (objectiveTask != null) { getInstance().setObjectiveTask(objectiveTask); } Associate associate = associateHome.getDefinedInstance(); if (associate != null) { getInstance().setAssociate(associate); } } public boolean isWired() { if (getInstance().getObjectiveTask() == null) return false; if (getInstance().getAssociate() == null) return false; return true; } public TaskAssignment getDefinedInstance() { return isIdDefined() ? getInstance() : null; } }
My seam page does have a page.xml file but the following is all it contains:
<page no-conversation-view-id="/StatusReport.xhtml" login-required="true"> <begin-conversation join="true"/> <action execute="#{taskAssignmentHome.wire}"/> <navigation from-action="#{taskAssignmentHome.update}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> <navigation from-action="#{taskAssignmentHome.remove}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> <navigation from-action="#{taskAssignmentHome.persist}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> </page>
For some reason, the code never invokes the setObjectiveTask on TaskAssignment, though its doing a get on it. Also, the <h:message/> shows that
value is required
, meaning objectiveTask was not set on TaskAssignment.Thanks
Amit -
6. Re: Problem with OneSelectMenu and entity selection
franciscoperedo Feb 25, 2008 5:42 PM (in response to amitdk)Hi!
Please, if you can post the code of StatusReport.xhtml
Regards,
LuxSpes -
7. Re: Problem with OneSelectMenu and entity selection
amitdk Feb 25, 2008 6:41 PM (in response to amitdk)Here's the part that submits to the TaskEdit.xhtml
<s:button view="/TaskEdit.xhtml" value="Add a Task"> <f:param name="associateId" value="#{user.associate.id}"/> </s:button>
Also, I posted the wrong page.xml - here's the correct one.
<page no-conversation-view-id="/StatusReport.xhtml" login-required="true"> <begin-conversation join="true"/> <param name="associateId" value="#{associateHome.associateId}"/> <action execute="#{taskAssignmentHome.wire}"/> <navigation from-action="#{taskAssignmentHome.update}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> <navigation from-action="#{taskAssignmentHome.remove}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> <navigation from-action="#{taskAssignmentHome.persist}"> <end-conversation/> <redirect view-id="/StatusReport.xhtml"/> </navigation> </page>
Could it be scope that is causing an issue here? I tried adding Scope(CONVERSATION) on taskAssignmentHome, and I also tried adding it to TaskAssignment (running out of ideas here ..:(), but with no luck.
- Amit
-
8. Re: Problem with OneSelectMenu and entity selection
amitdk Feb 25, 2008 8:23 PM (in response to amitdk)For whatever reason, looks like there wasn't anything wrong with my code. The same code works perfectly in Firefox, but does not work with IE 6.0. That's really strange....and this must surely be a bug with the SEAM code or maybe RichFaces.
- Amit
-
9. Re: Problem with OneSelectMenu and entity selection
pmuir Feb 26, 2008 1:53 PM (in response to amitdk)This should work, and as you say, it works in Firefox. If you manage to find the problem, file a JIRA so we can fix it :-)