// This is complete example of tacos tree with lazy loading of childrens in
non-ajax/traditional mode
// This example shows use case of, user displayed with multiple rows of
data, each of those rows has
// a tree component and details for individual tree's are fetched lazily.
Page definitions
<property name="treeState" persist="client" initial-value="ognl:new
java.util.HashSet()"/>
<component id="tree" type="tacos:Tree">
<binding name="contentProvider" value="new
com.abc.xyz.pages.TransactionTreeContentProvider
(currentTrans[tranIndex].transId,currentTrans[tranIndex].transType,currentTrans[tranIndex].details)"/>
<binding name="value" value="item"/>
<binding name="keyProvider" value="keyProvider"/>
<binding name="state" value="treeState"/>
<binding name="nodeLinkAjax" value="ognl:false" />
</component>
// currentTrans is an arrayList of VO's called Transactions
// currentTrans is present in ASO
// this is implementation of ITreeContentProvider
// creates trees with foll. data
// TransId - unique id for each transaction
// strParent - parent to be displayed
// strTransDetailsURL - some details that shall fetch children for that
parent
public TransactionTreeContentProvider(int TransId,String strParent,String
strTransDetailsURL){
Folder folder = new Folder(TransId,strParent,strTransDetailsURL);
ROOTS.add(folder);
}
// this method shall get invoked when user clicks on plus sign
// so write logic to fetch children
public Collection getChildren(Object parentElement) {
if (parentElement instanceof Folder) {
Folder folder = (Folder)parentElement;
String strDetails = folder .getDetailsurl();
if(folder.getItems().isEmpty() && strDetails!=null){
// some logic here
folder.item("From:");
folder.item("To:");
folder.item("Total Amount:");
}
else{
folder.item("There are no details for selected Transaction.");
}
List l = new ArrayList();
l.addAll(folder.getFolders());
l.addAll(folder.getItems());
return l;
}
return Collections.EMPTY_LIST;
}
// we need this to identify which plus sign was clicked by User
public class TransactionKeyProvider implements IKeyProvider {
public final static TransactionKeyProvider INSTANCE = new
TransactionKeyProvider();
public Serializable getKey(Object value)
{
Item a =(Item)value;
int intKey = a.getKeyId();
return intKey;
}
}
// Item and Folder implementation shall be custom - so I am copying it over
- I shall put the
// same if it's required by any one.
html code
<tr class="odd" jwcid="transaction"> --> this is for loop definition for
currentTrans
<td align="left">
<div id="tree" class="cData" jwcid="tree" style="overflow: auto; width:
auto; height: auto;">
<span class="cData" jwcid="@Insert" value="ognl:item.name"/>
</div>
</td>
<td valign="top"><span class="cdata" jwcid="amt"></span></td> -->
some other columns data
<td valign="top"><span class="cData" jwcid="effDate"></span></td> -->
some other columns data
<td valign="top"><span class="cData" jwcid="rcvDate"></span></td> -->
some other columns data
</tr>
Hope this helps.
Thanks
Mittal
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Tacos-devel mailing list
Tacos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tacos-devel