Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Greg Lindholm


 I have successfully used the display tag to iterate over a collection
 which is exposed in an action class. On each row in addition to the
 columns displaying the fields of each object in the collection, I
 embed two more struts-tag urls: Update and Remove.

 The objective is to have an extra two columns for every row in the
 table giving the ability to update or delete each record:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column property=entry /
display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
display:columna href=s:url action='UpdateEntryForm'
s:param name=name
 value=%{goalToAchieve.owner.fullName} /
/s:url
Edit/a/display:column
display:columna href=s:url action='DeleteEntryForm'
s:param name=name
 value=%{goalToAchieve.owner.fullName} /
s:property value=%{entry}/
   /s:url
   Remove/a/display:column
 /display:table

 I am having trouble passing the entry property, (or reference to it)
 to the url targeting the update or delete action. The entries
 collection consists of value type, embeddable objects. I am aware of
 how to pass parameters to the linking url, but my issue is passing a
 reference to the entry property of each row, to the update or delete
 action for the same row.


You didn't say what 'entry' is, but if it is a String or some primitive you
can just pass it as another parameter.

s:url action='DeleteEntryForm'
  s:param name=name value=%{goalToAchieve.owner.fullName} /
   s:param name=entry value=%{entry} /
/s:url

Usually, every database entity object has an 'id' property (primary key) and
you would just pass the id as a parameter so your action can find the object
in the database.

In you browser do a view source on the page to ensure the url is being
generated correctly with the params you are expecting.


Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks for the reply. Well, entry is an instance of a separate class:

@Embeddable
public class JournalEntry {
@org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;
@Column(length = 255, nullable = false)
private String entry;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();

...plus the getters and setters

This being a value type embeddable component, it is represented with a
table with only a foreign key to the parent entity it belongs to:
goalToAchieve_id

So, if I pass the entry String as a parameter (I am not sure if it
would be convenient to have a a few sentences as url params), how can
I turn it into a reference to the object I want to actually remove
from the collection?

Thanks again

On Mon, Jul 13, 2009 at 8:17 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:


 I have successfully used the display tag to iterate over a collection
 which is exposed in an action class. On each row in addition to the
 columns displaying the fields of each object in the collection, I
 embed two more struts-tag urls: Update and Remove.

 The objective is to have an extra two columns for every row in the
 table giving the ability to update or delete each record:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
        display:column property=entry /
        display:column property=date sortable=true
 defaultorder=ascending title=TimeStamp/
        display:columna href=s:url action='UpdateEntryForm'
                                s:param name=name
 value=%{goalToAchieve.owner.fullName} /
                        /s:url
                        Edit/a/display:column
        display:columna href=s:url action='DeleteEntryForm'
                                        s:param name=name
 value=%{goalToAchieve.owner.fullName} /
                                        s:property value=%{entry}/
                                       /s:url
                                       Remove/a/display:column
 /display:table

 I am having trouble passing the entry property, (or reference to it)
 to the url targeting the update or delete action. The entries
 collection consists of value type, embeddable objects. I am aware of
 how to pass parameters to the linking url, but my issue is passing a
 reference to the entry property of each row, to the update or delete
 action for the same row.


 You didn't say what 'entry' is, but if it is a String or some primitive you
 can just pass it as another parameter.

 s:url action='DeleteEntryForm'
          s:param name=name value=%{goalToAchieve.owner.fullName} /
           s:param name=entry value=%{entry} /
 /s:url

 Usually, every database entity object has an 'id' property (primary key) and
 you would just pass the id as a parameter so your action can find the object
 in the database.

 In you browser do a view source on the page to ensure the url is being
 generated correctly with the params you are expecting.


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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Greg Lindholm

 Thanks for the reply. Well, entry is an instance of a separate class:

 @Embeddable
 public class JournalEntry {
 @org.hibernate.annotations.Parent
private GoalToAchieve goalToAchieve;
 @Column(length = 255, nullable = false)
private String entry;

@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false, updatable = false)
private Date insertDate = new Date();

 ...plus the getters and setters

 This being a value type embeddable component, it is represented with a
 table with only a foreign key to the parent entity it belongs to:
 goalToAchieve_id

 So, if I pass the entry String as a parameter (I am not sure if it
 would be convenient to have a a few sentences as url params), how can
 I turn it into a reference to the object I want to actually remove
 from the collection?

 Thanks again

  You didn't say what 'entry' is, but if it is a String or some primitive
 you
  can just pass it as another parameter.
 
  s:url action='DeleteEntryForm'
   s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=entry value=%{entry} /
  /s:url
 
  Usually, every database entity object has an 'id' property (primary key)
 and
  you would just pass the id as a parameter so your action can find the
 object
  in the database.
 
  In you browser do a view source on the page to ensure the url is being
  generated correctly with the params you are expecting.
 


You definitely do not want to pass 'entry' as a parameter on the url.
Every database object needs some kind of unique key id just for situations
like this.
Maybe you could use the insertDate as a key (it's probably unique within
this context) but it would be better to add a key, perhaps a sequence number
so that goalToAchieve_id + seq is the PK.


Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
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.

On Mon, Jul 13, 2009 at 8:43 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:

 Thanks for the reply. Well, entry is an instance of a separate class:

 @Embeddable
 public class JournalEntry {
 @org.hibernate.annotations.Parent
        private GoalToAchieve goalToAchieve;
 @Column(length = 255, nullable = false)
        private String entry;

       �...@temporal(TemporalType.TIMESTAMP)
       �...@column(nullable = false, updatable = false)
        private Date insertDate = new Date();

 ...plus the getters and setters

 This being a value type embeddable component, it is represented with a
 table with only a foreign key to the parent entity it belongs to:
 goalToAchieve_id

 So, if I pass the entry String as a parameter (I am not sure if it
 would be convenient to have a a few sentences as url params), how can
 I turn it into a reference to the object I want to actually remove
 from the collection?

 Thanks again

  You didn't say what 'entry' is, but if it is a String or some primitive
 you
  can just pass it as another parameter.
 
  s:url action='DeleteEntryForm'
           s:param name=name value=%{goalToAchieve.owner.fullName} /
            s:param name=entry value=%{entry} /
  /s:url
 
  Usually, every database entity object has an 'id' property (primary key)
 and
  you would just pass the id as a parameter so your action can find the
 object
  in the database.
 
  In you browser do a view source on the page to ensure the url is being
  generated correctly with the params you are expecting.
 


 You definitely do not want to pass 'entry' as a parameter on the url.
 Every database object needs some kind of unique key id just for situations
 like this.
 Maybe you could use the insertDate as a key (it's probably unique within
 this context) but it would be better to add a key, perhaps a sequence number
 so that goalToAchieve_id + seq is the PK.


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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Greg Lindholm
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.



RE: updating or deleting a component from a collection through display tag

2009-07-13 Thread Martin Gainty

@Table(name = TableNameGoesHere)

//the java file would use ForeignKey annotation as described
@org.hibernate.annotations.ForeignKey(name = FK_GOALTOACHIEVE_ID)

public class WikiDocument extends WikiFileWikiDocument implements 
Serializable {
public String getHistoricalEntityName() {
return HistoricalWikiDocument;
}

and the hibernate configuration file (DatabaseObjects.hbm.xml) would handle the 
SequenceGeneration

hibernate-mapping package=org.jboss.seam.wiki.core.model 
default-access=field
class name=WikiDocument entity-name=HistoricalWikiDocument 
table=TABLE_NAME_GOES_HERE polymorphism=explicit
id name=PrimaryKey_In_Java_File column=PRIMARY_KEY_ID
generator class=org.hibernate.id.enhanced.SequenceStyleGenerator
param 
name=sequence_nameTABLE_NAME_PRIMARY_KEY__SEQUENCE/param
/generator
/id

WARNING: Despite (albeit brief) commentary offered 
any attempts to provide SEQUENCE generation to subvert SEQUENCE GENERATION by 
DBA is discouraged ..you do'nt want 2 sequences on same Table
i would encourage you to coordinate your SEQUENCE generation activity with DBA

fwiw
Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.



 Date: Mon, 13 Jul 2009 09:43:15 -0400
 Subject: Re: updating or deleting a component from a collection through   
 display tag
 From: greg.lindh...@gmail.com
 To: user@struts.apache.org
 
 
  Thanks for the reply. Well, entry is an instance of a separate class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
 private GoalToAchieve goalToAchieve;
  @Column(length = 255, nullable = false)
 private String entry;
 
 @Temporal(TemporalType.TIMESTAMP)
 @Column(nullable = false, updatable = false)
 private Date insertDate = new Date();
 
  ...plus the getters and setters
 
  This being a value type embeddable component, it is represented with a
  table with only a foreign key to the parent entity it belongs to:
  goalToAchieve_id
 
  So, if I pass the entry String as a parameter (I am not sure if it
  would be convenient to have a a few sentences as url params), how can
  I turn it into a reference to the object I want to actually remove
  from the collection?
 
  Thanks again
 
   You didn't say what 'entry' is, but if it is a String or some primitive
  you
   can just pass it as another parameter.
  
   s:url action='DeleteEntryForm'
s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=entry value=%{entry} /
   /s:url
  
   Usually, every database entity object has an 'id' property (primary key)
  and
   you would just pass the id as a parameter so your action can find the
  object
   in the database.
  
   In you browser do a view source on the page to ensure the url is being
   generated correctly with the params you are expecting.
  
 
 
 You definitely do not want to pass 'entry' as a parameter on the url.
 Every database object needs some kind of unique key id just for situations
 like this.
 Maybe you could use the insertDate as a key (it's probably unique within
 this context) but it would be better to add a key, perhaps a sequence number
 so that goalToAchieve_id + seq is the PK.

_
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
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 SetJournalEntry entries = new HashSetJournalEntry();

public SetJournalEntry getEntries() {
return entries;
}
public void setEntries(SortedSetJournalEntry 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 Lindholmgreg.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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks for the comments Martin, I will try it out!

On Mon, Jul 13, 2009 at 9:46 AM, Martin Gaintymgai...@hotmail.com wrote:

 @Table(name = TableNameGoesHere)

 //the java file would use ForeignKey annotation as described
 @org.hibernate.annotations.ForeignKey(name = FK_GOALTOACHIEVE_ID)

 public class WikiDocument extends WikiFileWikiDocument implements 
 Serializable {
    public String getHistoricalEntityName() {
        return HistoricalWikiDocument;
    }

 and the hibernate configuration file (DatabaseObjects.hbm.xml) would handle 
 the SequenceGeneration

 hibernate-mapping package=org.jboss.seam.wiki.core.model 
 default-access=field
    class name=WikiDocument entity-name=HistoricalWikiDocument 
 table=TABLE_NAME_GOES_HERE polymorphism=explicit
        id name=PrimaryKey_In_Java_File column=PRIMARY_KEY_ID
            generator 
 class=org.hibernate.id.enhanced.SequenceStyleGenerator
                param 
 name=sequence_nameTABLE_NAME_PRIMARY_KEY__SEQUENCE/param
            /generator
        /id

 WARNING: Despite (albeit brief) commentary offered
 any attempts to provide SEQUENCE generation to subvert SEQUENCE GENERATION by 
 DBA is discouraged ..you do'nt want 2 sequences on same Table
 i would encourage you to coordinate your SEQUENCE generation activity with DBA

 fwiw
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
 sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
 oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich 
 dem Austausch von Informationen und entfaltet keine rechtliche 
 Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen 
 wir keine Haftung fuer den Inhalt uebernehmen.



 Date: Mon, 13 Jul 2009 09:43:15 -0400
 Subject: Re: updating or deleting a component from a collection through      
  display tag
 From: greg.lindh...@gmail.com
 To: user@struts.apache.org

 
  Thanks for the reply. Well, entry is an instance of a separate class:
 
  @Embeddable
  public class JournalEntry {
  @org.hibernate.annotations.Parent
         private GoalToAchieve goalToAchieve;
  @Column(length = 255, nullable = false)
         private String entry;
 
        �...@temporal(TemporalType.TIMESTAMP)
        �...@column(nullable = false, updatable = false)
         private Date insertDate = new Date();
 
  ...plus the getters and setters
 
  This being a value type embeddable component, it is represented with a
  table with only a foreign key to the parent entity it belongs to:
  goalToAchieve_id
 
  So, if I pass the entry String as a parameter (I am not sure if it
  would be convenient to have a a few sentences as url params), how can
  I turn it into a reference to the object I want to actually remove
  from the collection?
 
  Thanks again
 
   You didn't say what 'entry' is, but if it is a String or some primitive
  you
   can just pass it as another parameter.
  
   s:url action='DeleteEntryForm'
            s:param name=name value=%{goalToAchieve.owner.fullName} /
             s:param name=entry value=%{entry} /
   /s:url
  
   Usually, every database entity object has an 'id' property (primary key)
  and
   you would just pass the id as a parameter so your action can find the
  object
   in the database.
  
   In you browser do a view source on the page to ensure the url is being
   generated correctly with the params you are expecting.
  
 

 You definitely do not want to pass 'entry' as a parameter on the url.
 Every database object needs some kind of unique key id just for situations
 like this.
 Maybe you could use the insertDate as a key (it's probably unique within
 this context) but it would be better to add a key, perhaps a sequence number
 so that goalToAchieve_id + seq is the PK.

 _
 Lauren found her dream laptop. Find the PC that’s right for you.
 http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290

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



Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Greg Lindholm
Looks like you need to change entry.mark to just mark and remove the
s:property value=%{entry}/. Also you probably don't need to pass both
the name and id of the parent object.

a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
   s:param name=id value=%{goalToAchieve.id} /
   s:param name=mark value=%{mark} /
   /s:url
Remove/a


On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
dimi@gmail.com wrote:

 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 SetJournalEntry entries = new HashSetJournalEntry();

public SetJournalEntry getEntries() {
return entries;
}
public void setEntries(SortedSetJournalEntry 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 Lindholmgreg.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




Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
I made the changes, but the view source indicates that the param
mark is not passed.

The url linked is formed like this:

/secure/DeleteEntryForm.action?name=firstName+lastNameid=1

The name and id params are fields of the parent object, the one
containing the collection.

Actually, I tried with all fields taken from the collection object,
like entry, and date but none gets passed as a param. Only properties
exposed by the parent object, goalToAchieve are passed, shouldn't I be
able to point to a field within a collection object too?

It looks like individual collection object properties can be viewed
using the iterator/display, but cannot be captured or passed as
parameters for any other uses... unless I am missing something, or
doing something wrong.


On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 Looks like you need to change entry.mark to just mark and remove the
 s:property value=%{entry}/. Also you probably don't need to pass both
 the name and id of the parent object.

 a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
       s:param name=id value=%{goalToAchieve.id} /
       s:param name=mark value=%{mark} /
   /s:url
 Remove/a


 On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 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 SetJournalEntry entries = new HashSetJournalEntry();

        public SetJournalEntry getEntries() {
                return entries;
        }
        public void setEntries(SortedSetJournalEntry 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 Lindholmgreg.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 

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Greg Lindholm
OK, I see the problem now...  you are not using s:iterator to go thru the
entries, you are using display:table.

The syntax suggested will not work since display:table does not know
anything about the value stack.The s:param name=mark value=%{mark} /
uses the value stack to resolve 'mark' which will not work here, you will
need to replace %{mark} with the right syntax to work with display:table
iterator.

And I don't know anything about display:table so you will need to look up
how to access the properties of the entities you are iterating over so as to
build the URL.


On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
s:param name=id value=%{goalToAchieve.id} /
s:param name=mark value=%{mark} /
/s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
 public SetJournalEntry getEntries() {
 return entries;
 }
 public void setEntries(SortedSetJournalEntry 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
  

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Yes, that is exactly the case, hmm.. Although, how is the
display:table tag finds the collection in the first place?

Supposedly the display has some way of reaching the valuestack, it can
even resolve the deeper notation display:table
name=goalToAchieve.entries

However, I will switch back to s:iterator to test if the syntax
suggested will work. I mainly used the display tag as a quick way to
sort the collection, but if I can't access the properties of the
objects I am iterating over, it isn't of much use in this case

On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry 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 

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Musachy Barroso
Assuming that each entry is named entry by displayTag, you can
access it using #attr.entry (or #attr['entry'])  to access it from
the S2 tags.

musachy

On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry 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 

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks. So, if I wanted to access a particular property (say this
property is called mark) of an entry object which I am iterating
over, I would do something like the following:

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='DeleteEntryForm' escapeAmp=false
s:param name=name value=%{goalToAchieve.owner.fullName} /
s:param name=id value=%{goalToAchieve.id} /
s:param name=date value=#attr.entry.mark /
   /s:url
Remove/a
/display:column

So, I could pass mark as a url param via s:url within the display tag?

Thanks for the information!

On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry 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;
 
  

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Musachy Barroso
The current row used by displaytag is pushed under the name set in
uid, so you could do this:

display:table name=goalToAchieve.entries requestURI= uid=thisGoal
display:column
a href=s:url action='DeleteEntryForm' escapeAmp=false
s:param name=date value=#attr.thisGoal.mark /
  /s:url
Remove/a
/display:column

musachy

On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 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='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look up
 how to access the properties of the entities you are iterating over so as 
 to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass 
  both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry 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
  

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Hey, this worked! Thanks Musachy, the tip you provided solved the
problem I was facing for the last 3 days.

I really appreciate your time to post this information. It looks like
the display tag packs much more functionality than it seems.

On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 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='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look 
 up
 how to access the properties of the entities you are iterating over so as 
 to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a collection object too?

 It looks like individual collection object properties can be viewed
 using the iterator/display, but cannot be captured or passed as
 parameters for any other uses... unless I am missing something, or
 doing something wrong.


 On Mon, Jul 13, 2009 at 10:50 AM, Greg Lindholmgreg.lindh...@gmail.com
 wrote:
  Looks like you need to change entry.mark to just mark and remove the
  s:property value=%{entry}/. Also you probably don't need to pass 
  both
  the name and id of the parent object.
 
  a href=s:url action='DeleteEntryForm' var=entry escapeAmp=false
        s:param name=id value=%{goalToAchieve.id} /
        s:param name=mark value=%{mark} /
    /s:url
  Remove/a
 
 
  On Mon, Jul 13, 2009 at 10:48 AM, Dimitrios Christodoulakis 
  dimi@gmail.com wrote:
 
  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 SetJournalEntry entries = new HashSetJournalEntry();
 
         public SetJournalEntry getEntries() {
                 return entries;
         }
         public void setEntries(SortedSetJournalEntry entries) {
                 this.entries = entries;
     

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Thanks again for helping out Musachy,
I was wondering if there are any rules regarding when the notation you
suggested below can be used. it works perfectly for setting url
params.

I was trying to use it (with struts2 tags) within a form (which is
within the display:column tag) to pass the value to an action:

display:column
s:form action=UpdateEntryForm
s:hidden name=mark value=#attr.thisEntry.mark /
s:hiddenname=name value=%{goalToAchieve.name} /
s:submit value=Edit/
/s:form
/display:column

This creates an Edit button in each row for every object I iterate
over, and I hoped to use the s:hidden tag to populate the underlying
UpdateEntryForm action. I also try to test it by printing from the
execute method as listed below, but the console output is just the
literal for the mark and zero for the primitive:

This id is: 0
This name is: #attr.thisEntry.mark

My action class:

public class UpdateEntryForm extends ActionSupport{
public String execute(){
System.out.println(This id is: + getId());
System.out.println(This name is: + getMark());
return SUCCESS; 
}
private String name;
private long mark;
public String getName() {
return name;
}
public void setName(String name){
this.name = name;
}

public String getMark() {
return mark;
}
public void setMark(String mark){
this.mark = mark;
}
}

Is there something wrong with the code above? Thanks again!

On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 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='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with display:table
 iterator.

 And I don't know anything about display:table so you will need to look 
 up
 how to access the properties of the entities you are iterating over so as 
 to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the param
 mark is not passed.

 The url linked is formed like this:

 /secure/DeleteEntryForm.action?name=firstName+lastNameid=1

 The name and id params are fields of the parent object, the one
 containing the collection.

 Actually, I tried with all fields taken from the collection object,
 like entry, and date but none gets passed as a param. Only properties
 exposed by the parent object, goalToAchieve are passed, shouldn't I be
 able to point to a field within a 

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Musachy Barroso
you can sue that notation anywhere. A tip that will save you a lot of
time, always wrap the OGNl expressions with %{}, that's why the first
hidden is not getting evaluated. The second one has an empty value
because goalToAchieve is probably not pointing to anything.

btw what #attr does is search for a value in all scopes (page,
request, session , application)

musahcy

On Mon, Jul 13, 2009 at 5:57 PM, Dimitrios
Christodoulakisdimi@gmail.com wrote:
 Thanks again for helping out Musachy,
 I was wondering if there are any rules regarding when the notation you
 suggested below can be used. it works perfectly for setting url
 params.

 I was trying to use it (with struts2 tags) within a form (which is
 within the display:column tag) to pass the value to an action:

 display:column
        s:form action=UpdateEntryForm
        s:hidden name=mark value=#attr.thisEntry.mark /
        s:hiddenname=name value=%{goalToAchieve.name} /
        s:submit value=Edit/
        /s:form
 /display:column

 This creates an Edit button in each row for every object I iterate
 over, and I hoped to use the s:hidden tag to populate the underlying
 UpdateEntryForm action. I also try to test it by printing from the
 execute method as listed below, but the console output is just the
 literal for the mark and zero for the primitive:

 This id is: 0
 This name is: #attr.thisEntry.mark

 My action class:

 public class UpdateEntryForm extends ActionSupport{
 public String execute(){
                System.out.println(This id is: + getId());
                System.out.println(This name is: + getMark());
                return SUCCESS;
        }
 private String name;
 private long mark;
 public String getName() {
                return name;
        }
        public void setName(String name){
                this.name = name;
        }

        public String getMark() {
                return mark;
        }
        public void setMark(String mark){
                this.mark = mark;
        }
 }

 Is there something wrong with the code above? Thanks again!

 On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 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='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} 
 /
 uses the value stack to resolve 'mark' which will not work here, you will
 need to replace %{mark} with the right syntax to work with 
 display:table
 iterator.

 And I don't know anything about display:table so you will need to look 
 up
 how to access the properties of the entities you are iterating over so 
 as to
 build the URL.


 On Mon, Jul 13, 2009 at 12:28 PM, Dimitrios Christodoulakis 
 dimi@gmail.com wrote:

 I made the changes, but the view source indicates that the 

Re: updating or deleting a component from a collection through display tag

2009-07-13 Thread Dimitrios Christodoulakis
Great, many thanks again for the information. I bet others will find
it pretty handy too!

On Mon, Jul 13, 2009 at 9:23 PM, Musachy Barrosomusa...@gmail.com wrote:
 you can sue that notation anywhere. A tip that will save you a lot of
 time, always wrap the OGNl expressions with %{}, that's why the first
 hidden is not getting evaluated. The second one has an empty value
 because goalToAchieve is probably not pointing to anything.

 btw what #attr does is search for a value in all scopes (page,
 request, session , application)

 musahcy

 On Mon, Jul 13, 2009 at 5:57 PM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks again for helping out Musachy,
 I was wondering if there are any rules regarding when the notation you
 suggested below can be used. it works perfectly for setting url
 params.

 I was trying to use it (with struts2 tags) within a form (which is
 within the display:column tag) to pass the value to an action:

 display:column
        s:form action=UpdateEntryForm
        s:hidden name=mark value=#attr.thisEntry.mark /
        s:hiddenname=name value=%{goalToAchieve.name} /
        s:submit value=Edit/
        /s:form
 /display:column

 This creates an Edit button in each row for every object I iterate
 over, and I hoped to use the s:hidden tag to populate the underlying
 UpdateEntryForm action. I also try to test it by printing from the
 execute method as listed below, but the console output is just the
 literal for the mark and zero for the primitive:

 This id is: 0
 This name is: #attr.thisEntry.mark

 My action class:

 public class UpdateEntryForm extends ActionSupport{
 public String execute(){
                System.out.println(This id is: + getId());
                System.out.println(This name is: + getMark());
                return SUCCESS;
        }
 private String name;
 private long mark;
 public String getName() {
                return name;
        }
        public void setName(String name){
                this.name = name;
        }

        public String getMark() {
                return mark;
        }
        public void setMark(String mark){
                this.mark = mark;
        }
 }

 Is there something wrong with the code above? Thanks again!

 On Mon, Jul 13, 2009 at 2:03 PM, Musachy Barrosomusa...@gmail.com wrote:
 The current row used by displaytag is pushed under the name set in
 uid, so you could do this:

 display:table name=goalToAchieve.entries requestURI= uid=thisGoal
 display:column
 a href=s:url action='DeleteEntryForm' escapeAmp=false
 s:param name=date value=#attr.thisGoal.mark /
  /s:url
 Remove/a
 /display:column

 musachy

 On Mon, Jul 13, 2009 at 11:17 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Thanks. So, if I wanted to access a particular property (say this
 property is called mark) of an entry object which I am iterating
 over, I would do something like the following:

 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='DeleteEntryForm' escapeAmp=false
 s:param name=name value=%{goalToAchieve.owner.fullName} /
 s:param name=id value=%{goalToAchieve.id} /
 s:param name=date value=#attr.entry.mark /
   /s:url
 Remove/a
 /display:column

 So, I could pass mark as a url param via s:url within the display tag?

 Thanks for the information!

 On Mon, Jul 13, 2009 at 1:08 PM, Musachy Barrosomusa...@gmail.com wrote:
 Assuming that each entry is named entry by displayTag, you can
 access it using #attr.entry (or #attr['entry'])  to access it from
 the S2 tags.

 musachy

 On Mon, Jul 13, 2009 at 10:27 AM, Dimitrios
 Christodoulakisdimi@gmail.com wrote:
 Yes, that is exactly the case, hmm.. Although, how is the
 display:table tag finds the collection in the first place?

 Supposedly the display has some way of reaching the valuestack, it can
 even resolve the deeper notation display:table
 name=goalToAchieve.entries

 However, I will switch back to s:iterator to test if the syntax
 suggested will work. I mainly used the display tag as a quick way to
 sort the collection, but if I can't access the properties of the
 objects I am iterating over, it isn't of much use in this case

 On Mon, Jul 13, 2009 at 12:20 PM, Greg Lindholmgreg.lindh...@gmail.com 
 wrote:
 OK, I see the problem now...  you are not using s:iterator to go thru 
 the
 entries, you are using display:table.

 The syntax suggested will not work since display:table does not know
 anything about the value stack.The s:param name=mark value=%{mark} 
 /
 uses the value stack to resolve 'mark' which will not work here, you 
 will
 need to replace %{mark} with the right syntax to work with 
 display:table
 iterator.

 And I don't know anything about display:table so you will need to 
 look up
 how to access the properties of the entities you are iterating over so 
 as