View unanswered posts | View active topics It is currently 2020-10-24 8:18



This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
 双击network网元 时,想得到后台node的名称 
Author Message
新手上路

Joined: 2012-12-06 17:59
Posts: 3
Post 双击network网元 时,想得到后台node的名称
<script type="text/javascript">
TWaver.Const.BASE_PATH = 'js/';
function init() {
var canvas = document.body;
var box = new TWaver.DataBox('NodeTwaverServlet');
var network = new TWaver.SVGNetwork(box, canvas);

network.addInputHandler({
//函数名为事件类型,传递参数evt为事件对象,component为事件派发者,也就是这个svg组件
doubleclick: function(evt, component){
alert(component);
}
});
box.update();
window.onresize = function() {
network.adjustBounds();
}

}
</script>

alert(component);弹出的是"TWaver.SVGNetwork",
后台定义一个node
Node node1 = new Node();
node1.setName("北京");
我想得到node的name,component这个参数应该有什么属性吧,怎么写啊。
哪位大师帮帮我呗,对TWaver不是很熟,如能解决真的非常感谢。


2012-12-06 18:12
Profile
本站元老

Joined: 2010-07-21 23:24
Posts: 1387
Post Re: 双击network网元 时,想得到后台node的名称
如果你对twaver不熟悉的话,应该先选好型,TWaver Web分支我们一般不再建议新客户新项目再采用,TWaver Flex,TWaver HTML5,TWaver Silverlight和TWaver Java都是更好的选择。


2012-12-06 23:05
Profile
本站元老

Joined: 2010-07-22 20:20
Posts: 1640
Post Re: 双击network网元 时,想得到后台node的名称
默认name属性没有输出
首先需要后台输出,通过SVGContext#setElementHeadCustomAttributeGenerator(...)(参看:http://doc.servasoftware.com/pages/viewpage.action?pageId=19005978)

参看RoomEditorDemo.java
Code:
      context.setElementHeadCustomAttributeGenerator(new Generator() {
         public Object generate(Object object) {
            String name = ((Element)object).getDisplayName();
            if(name == null){
               name = ((Element)object).getName();
            }
            if(name != null){
               return "name='" + WebUtil.xmlEscape(name) + "'";
            }
            return null;
         }
      });

前台:
Code:
var element = network.getElement(evt);
var name = element.getAttribute("name");


2012-12-07 9:47
Profile WWW
新手上路

Joined: 2012-12-06 17:59
Posts: 3
Post Re: 双击network网元 时,想得到后台node的名称
grin 谢谢可以了


2012-12-10 15:24
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron