-
1. Re: Outject Boolean
ohughes Dec 14, 2009 11:25 AM (in response to ohughes)I have now also tested with the New button, by setting the selected Entity to null during the processing of the method called when the button is clicked, but this seems to have no effect.
Is it too late in the lifecycle when I am attempting to do this?
Is there anyway to outject values at this point in the lifecycle??
Thanks again,
Osian -
2. Re: Outject Boolean
kragoth Dec 15, 2009 1:09 AM (in response to ohughes)I'm not sure why you need to outject anything.
Why can't you just write 3 methods.
public void createNew() { //do whatever you are supposed to do to create new editBean.setSelectedEntity(new Entity); editBean.redirect();//Do whatever you do to redirect to your page. } public void edit(Entity entityToEdit) { //do whatever you need to do to edit the entity editBean.setSelectedEntity(entityToEdit); editBean.redirect();//Do whatever you do to redirect to your page. } public void clone(Entity entityToClone) { //do whatever you need to do to clone the entity Entity clone = BeanUtils.clone(entityToClone); //Whatever you code is here to do the clone editBean.setSelectedEntity(clone); editBean.redirect();//Do whatever you do to redirect to your page. }
Now in your xhtml(NOTE: This is just off the top of my head and is wrong but the general idea should be ok.)
<h:commandButton value="New" action="#{SearchBean.createNew()}"/> <h:dataTable value="#{SearchBean.results} var="result" <!-- Do all your columns and data output here and then in one of the columns put these buttons --> <h:commandButton value="Edit" action="#{SearchBean.edit(result)}"/> <h:commandButton value="Clone" action="#{SearchBean.clone(result)}"/> </h:dataTable>
I'm not really sure on your requirements so not sure if this helps or not, but hopefully will give you some ideas. Maybe just make nice icon buttons to represent the edit and clone (this is what we have done in our app... an
E
icon for edit and you could do like aC
icon for clone). -
3. Re: Outject Boolean
ohughes Dec 15, 2009 4:55 PM (in response to ohughes)Thanks Tim.
I thought about this approach, but because the seam component for the Edit page is in page scope I had to come up with a slightly different solution.
I have an abstract base class which has 99% of the implementation, and then I have 3 classes which extend the base class. For the clone and edit they have the selected item injected into them, and then the clone pulls whatever values he needs to for the clone. Whereas the New doesn't have the selected row injected into him.
Then, to ensure that I didn't re-code everything for the facelets, I made a facelet component for the configuration of the object, and then it takes in a parameter of either the New, Clone or Edit concrete implementations, and all is well.
Thanks again,
Osian