SmartGWT Copy partial tree : leaf node to root node into other TreeGrid - gwt

I am using Treegrid widget of smartgwt.
I want to copy selected(partial) tree structure(leaf node to root node) from existing Treegrid to other TreeGrid.
I got ID's of selctedPath like "4/135/1456" from TreeGrid and Name of selected leaf node.
TreeGrid requires dataUrl( xml ) How to pass data of selected(partial) tree structure to 2nd TreeGrid ?
Is there any API for this case ?
User can add different partial tree in 2nd TreeGrid.
How to set this data to 2nd TreeGrid ?
Any help or guidance in this matter would be appreciated.

On your first TreeGrid use the getTree() methods to retrieve its underlying Tree object. There, use the available methods to retrieve an array of TreeNode objects for the required nodes you want to move over to the 2nd TreeGrid, e.g. getParents(TreeNode node), getDescendants(TreeNode node) etc. On the 2nd TreeGrid you can again call the getTree() and there use the add nodes methods, like the addList(TreeNode[] nodeList, TreeNode parent).

You can acheive the same with using drag and drop facility. In this you need not to use dataURL(XML). Try this..
http://www.smartclient.com/smartgwt/showcase/#tree_interaction_drag_nodes

Related

Autodesk forge highlight child object

Recently i've been working on this repository https://github.com/xiaodongliang/forgeviewer_embed_in_powerbi_report to build a custom visual in Power BI to visualize the issues extracted from Bim track'S API.
The idea was visualizing them in associaton to the model's ROOMS.
In order to do that I worked with a NWC file, so i cuold export rooms as a geometry.
What i would like to do now is to highligt the rooms if a connected issue is selected from a table.
The problem is When i select an issue from a table, in the selection tree i can see highlighted the parent object name (ROOM) instead of the child (solid), and i think that is why i can't achieve my purpose (if not please correct me).
what i have
what i wold like to do
Does anyone know a way to do that?
If you would like to change your selection between (FIRST_OBJECT, LAST_OBJECT, LEAF_OBJECT) you can change viewer selection settings in order to test:
If you would like to achieve this programmatically :
Viewer.setSelectionMode();
could help you as well.
If I well understood, you want to highlight the child (which contain the mesh) instead of the parent.
The object highlight (isolate) is done in /forgePowerbiView/src/visual.ts with this code:
const dbIds = options.dataViews[0].table.rows.map(r =>
<number>r[0].valueOf());
console.log('dbIds: ' +dbIds)
this.forge_viewer.showAll();
this.forge_viewer.impl.setGhostingBrightness(true); //for isolate effect
this.forge_viewer.isolate(dbIds);
Take a look at this link Enumerating leaf nodes on Viewer. This will help you to get the dbIds you want to isolate.

How to display a custom attribute on Cart Page in hybris?

I have a custom attribute whose value I have to display for every item in the cart on the Cart Page. I want to add the attribute in cartItem.tag. Can someone please tell me where should I add the value? I tried adding it in the CartPageController, but could not find an appropriate place to add the value.
I'm completely new to Hybris, any help would be appreciated.
Thanks, in advance.
I am guessing this new attribute belongs to the OrderEntryData type. You can use or create some Populator to add value to this attribute. You should use populators when you want to copy some value from modelObject to dataObject in order to show it whithin the presentantion layer.
Steps you need to follow:
Add new attribute on CartEntryModel at item level where, your new attribute value will get store on model
Add new attribute in CartData using **beans.xml, which will hold and show value on cart page
Create new custom populator by extending commercefacades's "CartPopulator" and populate new attribute value
Finally, you can use new attribute directly on cartPage via. cartEntry.newAttribute

AEM DefaultValue written to JCR

I noticed that when I set my defaultValue for a dropdown, altho it is correctly selected in the drop down when I first add my component to the page it does not write the defaultValue to the corresponding JCR until I edit the component and save it. Even if I just open the corresponding dialog and click OK now my component works as expected because the values have been added to the JCR.
I am sure there is an important piece that I am missing here, does anyone knows how defaultValues that are required in order for the component to render properly can be added to the JCR when they are first added to the page?
Like Shwan say's that's the way it works. The default values or empty texts are only for the dialog. They aren't persisted until the dialog is authored. The properties have to be set by a different method. CQ already ships with this feature and you can do it without any custom code.
Under your component , create a node called cq:template[nt:unstructured] . If all the data is stored on the component node itself , add the default values as properties to cq:template node with name same as the ones in your dialog. In case the data is stored in a child node add a similar node under cq:template node.
Source : http://blogs.adobe.com/experiencedelivers/experience-management/defaults-in-your-component/
I believe that is simply the way it works. The default value specified in a dialog does not get used until the dialog is loaded/saved, so until that happens the node on the JCR repository that is being authored won't have the default value.
We got around this on a project by adding back-end code that was tied to the component (a tag) so that when the component was loaded, if the property did not exist, it would be written with the default the first time. Ex:
if (wcmMode == WCMMode.EDIT )
{
if(!currentNode.hasProperty("SomePropertyThatWillAlwaysExistIfTheDialogHasBeenSaved")) {
currentNode.setProperty("PropertyThatShouldHaveDefault", GlobalConstants.TRUE);
currentNode.getSession().save();
}
}
Like Sharath Madappa say's that's the way it works fine if component name and jsp name same. If you dont have componentname.jsp under component or page, cq:template won't work.(Reference:http://labs.6dglobal.com/blog/2014-07-08/using-the-cq-template/)
If you hava componentname.html under your component, changed the node [cq:template] type to [cq:Template] instead of [nt:unstructured]. In this case, defaultValues can be added to the JCR when they are first added to the page.

Access jcr:content propeties from page node

I have dropdown where the values of options are like jcr:content/jcr:title, jcr:content/jcr:description, /jcr:content/par/entry/text etc. Here the last one is the property of parent, like jcr:title is the property of jcr:content node & text is the property of entry node, but entry has parent par and par has parent jcr:content. I am at the page node and using the below code to fetch such values which doesn't work :
Node n = (Node)nodeIter.next();
log.info(n.getProperty("/jcr:content/par/entry/text"));
Any Idea how to get values in such a way.
Thanks
Remove the starting slash from the property path. It makes the path absolute while you are interested in the relative one (as in other examples you've described):
n.getProperty("jcr:content/par/entry/text");

Get parent element name in XPath

I am trying to figure out how to get the name of the parent from a text node's scope.
//text()[name(parent)='p']
How can you get the name of the current node's parent?
If you're trying to test the name, you almost had it:
//text()[name(parent::*)='p']
If you're trying to return the name:
name(//text()/parent::*)
FYI, point of terminology: a text node is not an element.
Anyway, the most succinct way to select the parent of the current node is ..
So, the name of the parent element of the current node (which could be a text node) is name(..)
Substituting that into your XPath expression:
//text()[name(..)='p']
But a less roundabout way to write that would be
//p/text()
(assuming the p elements in the document have no namespace prefix). Either way, you're selecting all text nodes that are children of elements named p.
//text/..[#name='p']
This will get all parents of <text> nodes as long as the parent has a name attribute of p.