-
1. Re: Rendering buttons in a datatable fails
app4you Mar 12, 2007 12:48 PM (in response to hubaer)Hello,
You might want to check the followings:
1. The search result actionBean should be in Session scope (can be conversation scope), or the search result list object has to be in session scope
2. For the editable checking for each record, then put it @Transient isEditable in the entity bean level
3. In the entryAction, use @Begin or @Begin(join=true) public ... edit(... entry)
Hope this could help. -
2. Re: Rendering buttons in a datatable fails
hubaer Mar 12, 2007 3:51 PM (in response to hubaer)Thank you app4you for your answers.
I checked your suggestions, but without any success.
The DataModel was allready in a conversion scope.
The editable check works showing only the entries which can be edited.
The edit-Action is never called, so the @Begin can't start a conversion :-(
But I played a little bit with the rendered attribute. I changed the editable check in the entryAction for test reason that it always returns true. Then it works as in the first example.
Can the DataModel not dereference the selected entity if there is not a button in each row?
Thanks for help
Marco -
3. Re: Rendering buttons in a datatable fails
svadu Mar 12, 2007 4:41 PM (in response to hubaer)1. Try to place <h:messages/> and see if it gives any errors.
2. I am not sure whether h:commandButton supports arguments (try <s:button/>?) -
4. Re: Rendering buttons in a datatable fails
hubaer Mar 13, 2007 6:06 AM (in response to hubaer)Hi svadu,
<h:messages /> was already placed. But no error is printed.
I tried the <s:button> before, but without any changes in the behavior of the page.
The <h:commandbutton> supports arguments. If you look in my initial post there is already an attribute pasing to the action bean. And this example works. -
5. Re: Rendering buttons in a datatable fails
app4you Mar 13, 2007 9:06 AM (in response to hubaer)Hello,
the h:commandButton does not support parameter passing. Use s:button or s:link for parameter passing.
If your stateful session List object contains the @DataModel, then it should work in the DataTable using <s:button or h:commandButton.
There got to be something missing. Please show your code snippet, xhtml and bean.
Thanks -
6. Re: Rendering buttons in a datatable fails
hubaer Mar 13, 2007 9:47 AM (in response to hubaer)Thank you so far.
Ok, here some code snippets.
The xhtml is similar as in the first post. I put only the rendered attribute on the commandButton:<h:form> <h:dataTable var="entry" value="#{entryList}" rendered="#{entryList.rowCount>0}"> <h:column> <f:facet name="header"> <h:outputText value="Title"/> </f:facet> <h:outputText value="#{entry.title}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Status"/> </f:facet> <h:outputText value="#{entry.status}"/> </h:column> <h:column> <h:commandButton value="Edit" action="#{entryAction.edit(entry)}" rendered="#{entryAction.editable}"/> </h:column> </h:dataTable> </h:form>
Here is some code from the corresponding action bean:@Stateful @Name("entryAction") @Scope(ScopeType.CONVERSATION) public class EntryActionBean implements EntryAction, Serializable { private Logger log = Logger.getLogger(EntryActionBean.class); @DataModel private Set<Entry> entryList; @DataModelSelection private Entry entry; @Factory("entryList") public void initEntryList() { log.info("initEntryList"); entryList = getEntryList(); } public boolean isEditable() { return checkEditable(entry); } public String edit(Entry entry) { log.info("edit Entry " + entry); return "editEntry"; } @Remove @Destroy public void destroy() { log.info("Called @Remove/@Destroy"); } ... }
I also tried out the s:button, but there is no parameter passing to the action bean. I get always a null value.
Hope that helps.
Marco -
7. Re: Rendering buttons in a datatable fails
app4you Mar 13, 2007 10:17 AM (in response to hubaer)Here's wat to do to resolve it
1. Either make the datamodel list object into the session scope
2. or create another action bean to handle the editEntry action
3. Don't use h:commandButton with parameter. Don't know why you did n't receive the JSF expression error for doing this passing. USE <s:button> instead. -
8. Re: Rendering buttons in a datatable fails
hubaer Mar 13, 2007 11:13 AM (in response to hubaer)Thank you app4you,
So I played another time with my application and I think I resolved the problems with your help.
I couldn't put the DataModel in the session scope, because it is only allowed to put it in the page or undefined scope.
But I put an @Begin at my factory method. So the action bean stays in the conversions. That's ok for me.
Now I can pass parameter via the s:button (The commandButton works too !?!, but I change to the s:button).
I tried out creating a 2nd bean for the edit action. But it also works now if all is in the same bean.
I think, it must be the conversation.
So now the buttons are only shown on those entries, which are editable and the correct entry is passed if I click on "Edit"!
Thanks again
Marco -
9. Re: Rendering buttons in a datatable fails
app4you Mar 13, 2007 3:31 PM (in response to hubaer)Yo're welcomed. Glad i could help.