File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes representing matryoshka object in form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "representing matryoshka object in form" Watch "representing matryoshka object in form" New topic
Author

representing matryoshka object in form

Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
I have case like this:






If object B doesn't have collection, we only need to represent B as grid B and then save the object. But how do I represent this case? one solution crossed my mind is using another grid. so everytime the row selected in grid representing object B is changing, the grid representing C changes to display C objects owned by the currently selected object B.but this poses another problem. I want to send the data by json to the server. lets say grid B has 5 B objects, and right now object B number 2 is selected, so grid C displays list of C objects of B number 2 only. So I cannot include the C objects of the other 4 B objects in the json string I'm about to send to server. Some help please? thanks
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
I think you may want to post a little more code so people can follow what you are trying to do.


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
I don't have the code yet. It's still conceptual. Because of this problem, my coding process is halted. But is the problem clear to you? I'm still thinking of the layout design that can accommodate this case.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
actually I'm asking about how to design the html layout for this problem, so html/javascript section sounds quite appropriate. But if you think it should be moved, I don't really mind. thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

I don't understand any of that question. I suppose that might be because the classes are named A, B, and C, though, which increases the coefficient of meaninglessness. You're talking about grids, and then collections, and then objects, and then sending data to servers... so there's a bit of GUI design, a bit of data design, a bit of describing actions, all about some unnamed objects which contain basically no useful data.

And yes, your coding process certainly should be halted. You don't have anything which you can write code for. So carry on designing until you have something which you can describe.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
since this is still an idea (none of my projects have encountered such case, but somehow this morning I thought of it, so why not prepare even if this case hasn't happened yet). lets say you have 5 sons, and each of these sons of yours has 3 sons. For your details, I can simply use textboxes to store your name, DOB and age. as for your sons, a grid will do (it consists of 3 columns : name,age,DOB, just like your details). Now the problem is with your grandsons. What I think now is adding another grid below your son's grid (lets say grandson grid). If I select son number 2 in son's grid, the grandson grid will display the details of son number 2's sons (but none of the remaining 4 sons' sons). As far as I know I can only grab data displayed at the screen, so I'm missing the details of the other 4 sons' sons when I build my json string.

@Paul Clapham:
Clear enough ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

Then you certainly don't need different classes for the levels. If the classes represent men, then a Man class contains his name and a list of his sons, who are also, um, Man objects.

Hengki Widjaja wrote:As far as I know I can only grab data displayed at the screen


Of course that isn't true at all. You can "grab" any data which you have in your data model.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
okay:








Is this about right? So how do you propose I build the json string ? Remember, we're in the view right now (i.e. html displayed in the browser, client-side) not some java file, that's why I thought this question should be put in HTML section. Right now the layout design is your detail, your sons' detail in grid Son and your sons' son's details in grid Grandson. as I've said earlier, the problem is with the grandson details. how do I get them when I build json?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
There is something peculiar about a Son who doesn’t have a Father. I am not convinced you have got that inheritance tree at all right.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
That's just a representation in the java side. I'm looking for the appropriate layout strategy for this scenario in my html. The inheritance doesn't matter. Perhaps I chose the wrong analogy since the focus seems to have shifted to inheritance which is not my question. My problem is a grid which each of its rows has their own details. What I've encountered until now is just a case like an receipt with a list of stuff to buy. For this, a couple of textboxes for the receipt info(like the date of purchase, buyer's name, etc) followed by a grid of things to buy will do the trick. Hopefully this is clear enough to describe my problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Hengki Widjaja wrote: . . . But is the problem clear to you? . . .
No. Are you interested in a hierarchy of objects, or a hierarchical display?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: representing matryoshka object in form