Thanks for letting me know. Alright, so:

This is the parent class:

@Entity
public class GoalToAchieve {
@Id @GeneratedValue
private Long id;
        
@org.hibernate.annotations.CollectionOfElements
@JoinTable (name="GoalToAchieve_entry",
joincolum...@joincolumn(name="goalToAchieve_id"))
private Set<JournalEntry> entries = new HashSet<JournalEntry>();
        
        public Set<JournalEntry> getEntries() {
                return entries;
        }
        public void setEntries(SortedSet<JournalEntry> entries) {
                this.entries = entries;
        }
        
        public void addEntry(JournalEntry newEntry){
                entries.add(newEntry);
        }
        
        public void deleteEntry(JournalEntry entry){
                entries.remove(entry);
        }
..plus some other standard fields with getters and setters

This is the child-class:

@Embeddable
public class JournalEntry {
@org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;
        
@Column
private Long mark;
public Long getMark() {
        return mark;
}
public void setMark(long mark){
        this.mark = mark;
        }
        
@Column(length = 255, nullable = false)
private String entry;
        
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();

..plus the rest getters and setters

And this this the jsp part where I display the collection:

<s:if test="goalToAchieve.entries.size > 0">
<display:table name="goalToAchieve.entries" requestURI="" uid="thisGoal">
        <display:column property="entry" />
        <display:column property="date" sortable="true"
defaultorder="ascending" title="TimeStamp"/>
        <display:column property="mark" />
  <display:column>
<a href="<s:url action='UpdateEntryForm'>
        <s:param name="name" value="%{goalToAchieve.owner.fullName}" />
        <s:param name="mark" value="#mark" />
    </s:url>
    ">Edit</a>
</display:column>
<display:column>
<a href="<s:url action='DeleteEntryForm' var="entry" escapeAmp="false">
        <s:param name="name" value="%{goalToAchieve.owner.fullName}" />
        <s:param name="id" value="%{goalToAchieve.id}" />
        <s:param name="mark" value="entry.mark" />
        <s:property value="%{entry}"/>
    </s:url>
">Remove</a>    
</display:column>
</display:table>
</s:if>

..and the delete action, which should take an entry reference and
remove it from the collections looks like this:

public class DeleteEntry extends ActionSupport{
public String execute(){
                goalToAchieve.deleteEntry(entry);
                
                return SUCCESS;
        }
        
        private JournalEntry entry;
        private GoalToAchieve goalToAchieve;
        private long id;

... + getters and setters

I guess right now, my problem has become how to pass a parameter
referring to en entry (the mark field) to the delete action. Next, I
would do a lookup within the action to find the entry object and
remove it from the parent object collection, by calling
deleteEntry(JournalEntry entry)

On Mon, Jul 13, 2009 at 9:16 AM, Greg Lindholm<greg.lindh...@gmail.com> wrote:
> You are not providing enough information for anyone to help you. Since you
> have changed your object and the jsp you had better include them with any
> request.
>
>
> On Mon, Jul 13, 2009 at 9:51 AM, Dimitrios Christodoulakis <
> dimi....@gmail.com> wrote:
>
>> Yes, that is a great suggestion actually. What I did was to add a new
>> field based
>> System.currentTimeMillis(), but the problem is adding it as a url
>> parameter.
>>
>> For example, I am trying to add it as a url parameter below:
>>
>> <a href="<s:url action='UpdateEntryForm'>
>> <s:param name="name" value="%{goalToAchieve.owner.fullName}" />
>> <s:param name="mark" value="%{mark}" />
>> </s:url>
>>  ">Edit</a>
>>
>> But, the only param passed is the fullName. The mark is not added to
>> the url string. I think this is because the only object available on
>> the valuestack is goalToAchieve, and using deeper notation I can
>> reference as deep as the "entries" collection. But not to fields of
>> each entry object. In other words, the display or iterator help me
>> view the collection objects, but not extract and use any of their
>> fields... I am not sure why this is happening, or if I am doing
>> something wrong.
>>
>

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

Reply via email to