Good afternoon,

I am re-stating a problem I am facing, for which I provided a kind of
complicated description before: Deleting objects from a collection.
The owning, parent object is a hibernate persistent entity, which
contains a collection of components (value-type objects). Such
components don't have shared references, which means that removing a
component from the collection results in deleting the object from the
database.

I am calling an action which exposes the parent entity, goalToAchieve,
and the result page iterates over the collection
goalToAchieve.entries:

<display:table name="goalToAchieve.entries" requestURI="" uid="thisGoal">
    <display:column property="entry" />
    <display:column property="date" sortable="true"
defaultorder="ascending" title="TimeStamp"/>
</display:table>

The above works, fine. Each row of the table is an instance of the
JournalEntry class displaying two fields: an entry of type String and
a date of type Date. My objective is to give the user the option to
update or delete each row right from the table view. So, I thought to
add two more columns in each row: Update or Delete. I have not been
able to implement this properly, I tried with a url, and with a form.
My guess is that I cannot pass a reference to the row back to the
action performing the delete or update. Am I making this more
complicated than it really is? What can I be missing?

I tried adding one more column like this, hoping the entry property
will be available to the DeleteEntry action via the mini-form.

<display:column>
<s:form action="DeleteEntry">
    <s:property value="entry"/>
    <s:hidden name="id" value="%{goalToAchieve.id}" />
   <s:submit value="Remove"/>
</s:form>
</display:column>

The DeleteEntry action has all the getters and setters:

public String execute(){
                goalToAchieve = getSubscriberService().getGoalToAchieve(id);
                goalToAchieve.deleteEntry(entry);
                
                return SUCCESS;
}

public void setEntry(JournalEntry entry){
                this.entry = entry;
}
        
public JournalEntry getEntry(){
                return entry;
}

But I get java.lang.NullPointerException: actions.DeleteEntry.execute

1) I am not sure if the reference to the entry is passing over to the
action, and
2) if it does, seems like there is no entry object instantiated. But
the entry was instantiated at the time of the insert.

Any ideas about this, and general guidelines on deleting objects from
collections?

Appreciate the help.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to