A tree widget is basically a bunch of collapsible containers, when you open a node all it's child nodes becomes visible, and when you close it they're hidden. The basic idea is that simple however there are a few things that makes it a bit more complicated. Below you'll find information about parts of the implementation of this tree widget, how the generated code looks like and how a few of the methods work. This is not something you need to read and understand in order to use this widget, however if you're interested in how this was made and how it works you might find this helpful.

Generated Code

As described earlier the tree widget uses an object hierarchy implementation to simplify the creation of trees, however since the browser cannot understand that object hierarchy we are required to convert it into something that the browser can render, in this case guess what we're using? Yeah you where right, our old buddy html. Below is the generated html code for a small tree with only three items. Further down this document you'll find the same code but split up and described.

<div id="webfx-tree-object-0" ondblclick="webFXTreeHandler.toggle(this);" class="webfx-tree-item">
  <img id="webfx-tree-object-0-icon" src="images/openfoldericon.png" onclick="webFXTreeHandler.select(this);">
  <a href="javascript:void(0);" id="webfx-tree-object-0-anchor">Root</a>
</div>
<div id="webfx-tree-object-0-cont" class="webfx-tree-container" style="display: block;">
  <div id="webfx-tree-object-1" class="webfx-tree-item">
    <img id="webfx-tree-object-1-plus" src="images/L.png">
    <img id="webfx-tree-object-1-icon" src="images/new.png" onclick="webFXTreeHandler.select(this);">
    <a href="javascript:void(0);" id="webfx-tree-object-1-anchor">1</a>
  </div>
  <div id="webfx-tree-object-2" class="webfx-tree-item">
    <img id="webfx-tree-object-2-plus" src="images/L.png">
    <img id="webfx-tree-object-2-icon" src="images/new.png" onclick="webFXTreeHandler.select(this);">
    <a href="javascript:void(0);" id="webfx-tree-object-2-anchor">2</a>
  </div>
  <div id="webfx-tree-object-3" class="webfx-tree-item">
    <img id="webfx-tree-object-3-plus" src="images/L.png">
    <img id="webfx-tree-object-3-icon" src="images/new.png" onclick="webFXTreeHandler.select(this);">
    <a href="javascript:void(0);" id="webfx-tree-object-3-anchor">3</a>
  </div>
</div>

WebFXTree Object

The code below is what is generated from the WebFXTree Object (it will however also contain the code from all tree items but to increase the readability that code has been removed).

<div id="webfx-tree-object-0" ondblclick="webFXTreeHandler.toggle(this);" class="webfx-tree-item">
  <img id="webfx-tree-object-0-icon" src="images/openfoldericon.png" onclick="webFXTreeHandler.select(this);">
  <a href="javascript:void(0);" id="webfx-tree-object-0-anchor">Root</a>
</div>
<div id="webfx-tree-object-0-cont" class="webfx-tree-container" style="display: block;">
  <!-- This is where the Tree Item's will be inserted -->
</div>

The first div contains the top level icon and label while the secund div is the container that will house the tree items. When the first div is double clicked the display property of the secund one will be toggled.

WebFXTreeItem

The code below is what is generated from a singel WebFXTreeItem Object.

<div id="webfx-tree-object-1" class="webfx-tree-item">
  <img id="webfx-tree-object-1-plus" src="images/L.png">
  <img id="webfx-tree-object-1-icon" src="images/new.png" onclick="webFXTreeHandler.select(this);">
  <a href="javascript:void(0);" id="webfx-tree-object-1-anchor">1</a>
</div>

As you can see the code generated by each WebFXTreeItem looks pretty much the same as the one for the WebFXTree object, the main difference is the extra image(s) that the tree items has (the plus/minus and track icons). Also note that the code shown above is from a tree item without children. If the tree item has children an extra div to contain those will be added (much like the secund div generated by the WebFXTree Object).

Expanding/Collapsing

The most important methods for this widget are expand and collapse. Here I'll try to describe how those works. As the html code above showed webFXTreeHandler.toggle(this); is executed once a tree item is clicked. The tree handler then uses an internal reference, webFXTreeHandler.all to look up the object for the clicked tree item. Once the object has been found it executes the toggle() method on that object.

Below is the code for the toggle method and as you can see all it does is to check whatever or not the item is currently expanded or collapsed, and then calls the appropriated method (expand if it's collapsed or collapse if it's expanded).

WebFXTreeItem.prototype.toggle = function () {
  if (this.open) { this.collapse(); }
  else { this.expand(); }
}

Since the expand and collapse methods works pretty much the same I'll only describe one of them, the expand method.

WebFXTreeItem.prototype.expand = function () {
  if (!this._subItems.length > 0) { return; }
  document.getElementById(this.id + '-cont').style.display = 'block';
  document.getElementById(this.id + '-icon').src = openFolderIcon;
  document.getElementById(this.id + '-plus').src = this.minusIcon;
  this.open = true;
  setCookie(this.id.substr(18,this.id.length - 18), '1');
}

The first line of code checks to see if there are any children, since it doesn't do any good to expand it unless there are. The next line is the most important one and does the expanding by changing the display mode of the div containing all children to block. The next two lines changes the icon and the plus/minus sign, then the open property is changed to reflect the expanded/collpased state and finally it sets a cookie (used to keep track of what's expanded or not so that the tree can be restored to it's previous state the next time you visit the site).

posted @ 2010-07-20 22:50 .NET JAVA园 阅读(52) 评论(0) 编辑

This tree widget is based on objects and all html code is generated from a js structure. To create a tree you won't have to write a single line of html however you will have to learn how to to create the tree and treeItem objects.

Usage

The tree(s) needs to be create during the initial load phase of the page. This is accomplished by creating a WebFXTree object and then add WebFXTreeItems to it. Once all items has been added document.write is used to generate the html code and insert it into the page.

  var tree = new WebFXTree('Root');
  tree.add(new WebFXTreeItem('Tree Item 1'));
  tree.add(new WebFXTreeItem('Tree Item 2'));
  tree.add(new WebFXTreeItem('Tree Item 3'));
  document.write(tree);

Folders

A folder is created by adding a new tree item to a already created tree item. However since we need to keep a reference to this tree item object (so that we can add tree items to it, and make it a folder) we cannot create the new object inside the add method. So instead we first create the new tree item object and then we add it to the tree.

  var tree = new WebFXTree('Root');
  /* Add tree item to tree */
  tree.add(new WebFXTreeItem('1'));
  /* Create a new folder and add it to tree */
  var folder = new WebFXTreeItem('2')
  tree.add(folder);
  /* Add tree items to folder */
  folder.add(new WebFXTreeItem('2.1'));
  folder.add(new WebFXTreeItem('2.2'));
  folder.add(new WebFXTreeItem('2.3'));
  /* Add another tree item to tree */
  tree.add(new WebFXTreeItem('3'));
  document.write(tree);

Explorer behavior

Since I first published this tree control I've been getting a lot of requesters about making it contain only folders. So I added a setBehavior method to it. The example below is an exact copy of the one above, with the one exception that this uses tree.setBehavior('explorer');

  var tree = new WebFXTree('Root');
  /* Change the behavior of the tree */
  tree.setBehavior('explorer');
  /* Add tree item to tree */
  tree.add(new WebFXTreeItem('1'));
  /* Create a new folder and add it to tree */
  var folder = new WebFXTreeItem('2')
  tree.add(folder);
  /* Add tree items to folder */
  folder.add(new WebFXTreeItem('2.1'));
  folder.add(new WebFXTreeItem('2.2'));
  folder.add(new WebFXTreeItem('2.3'));
  /* Add another tree item to tree */
  tree.add(new WebFXTreeItem('3'));
  document.write(tree);

Custom Icons

Some times you might want to combine the two styles, or make some of the folders/items have a different icon than the default. To achieve that set the object.icon property to an uri, or to a javascript variable containing one. To change the open icons for folders use object.openIcon.

  var tree = new WebFXTree('Root');
  tree.setBehavior('explorer');
  tree.icon = 'http://webfx.eae.net/images/notepad.gif';
  tree.add(new WebFXTreeItem('1'));
  var folder = new WebFXTreeItem('2')
  tree.add(folder);
  var t21 = new WebFXTreeItem('2.1');
  /* Change the icon */
  t21.icon = webFXTreeConfig.fileIcon;
  folder.add(t21);
  var t22 = new WebFXTreeItem('2.2');
  /* Change the icon */
  t22.icon = webFXTreeConfig.fileIcon;
  folder.add(t22);
  var t23 = new WebFXTreeItem('2.3');
  /* Change the icon */
  t23.icon = webFXTreeConfig.fileIcon;
  folder.add(t23);
  tree.add(new WebFXTreeItem('3'));
  document.write(tree);
posted @ 2010-07-20 22:44 .NET JAVA园 阅读(57) 评论(0) 编辑
Licensed under the Apache Software License 2.0

This component may be obtained, modified and distributed free of charge for personal as well as commercial use. Please see the license for the complete terms and exact wording.

(2006-05-26) Changed license to Apache Software License 2.0.
(2003-03-16) Version 1.17 - Added target property.
(2003-02-15) Version 1.16 - The selected node can now be distinguished even when the tree control loses focus.
(2002-10-29) Version 1.15 - This version is based on 1.13 and fixes the bugs 1.14 were supposed to fix.
(2002-10-23) Version 1.14 - Minor fix for a case where the plus icon used wrong image.
(2002-08-20) Version 1.13 - Added usePersistence flag to allow disable the usage of cookies.
(2002-06-13) Version 1.12 - Various bug fixes.
(2002-01-27) Version 1.11 - Bug fixes and improved mozilla support.
(2001-09-23) Version 1.1 - New features included keyboard navigation (ie) and the ability to add and remove nodes dynamically and some other small tweaks and fixes.
(2001-03-18) Added getSelected and get/setBehavior that can make it behave more like the windows explorer
(check usage for more information about it).
(2001-01-10) Original Version Posted.

An object based tree widget with persistence using cookies that works in ie5 and mozilla.

History

Among the first things I created with DHTML was a tree view, that was over four years ago (spring 1997), since then a lot has happened in the browser market, and also with my skills in JavaScript and DHTML. Today I give you the third version of this tree view widget. The idea behind it is the same as in the first version, to emulate the tree widget found in many modern graphical operation environments, such as Microsoft Windows, and so is the basic idea of how to accomplish this, to toggle the display property of elements depending on the expanded state of their parents. However the similarities stop there. Another thing I can mention from a historical point of view is that this is the first complex script that I have created that works under two different browsers without the use of browser detection, the same code is actually used for ie5 and mozilla. :o)

Introduction

This new version is based on objects, so you do not create the actual html code for the tree yourself, you create an object (the tree's root folder) and then you add child items to this. Once you're done adding items the actual html code is generated and inserted into the page. This makes it very easy to create and update the content of the tree (or to dynamically generate it). If you've seen Erik's new xMenu you will notice that it's working in similar way.

Persistence

This script also features persistence using per session cookies. So now if you go to a page using this tree widget, expand a few folders and then leave the page again (by following a link or by typing a new url manually) it will store the state of each folder in a cookie so when you go back to the page it will remember what folders you last had opened and open them for you. This could be very useful if you use this for site navigation etc.

Limitations

The persistence functionality is using the node creation order to remember the state of each node, this works fine for static trees, but not for dynamic ones since adding and/or deleting nodes will change the original order numbering.

posted @ 2010-07-20 22:43 .NET JAVA园 阅读(74) 评论(0) 编辑

WebFXTreeAbstractNode

Abstract object with common functions and methods shared by WebFXTree and WebFXTreeItem. The two of those inherites from this object.

Constructor

Abstract object - no instances of it should be created

Properties

Name Type Description
id Number Read only property that can be used to find the related HTMLElement. It can also be used the other way around. If you know the id of the HTMLElement you can get the JS object by looking in the webFXTreeHandler.all collection.
text String The text label for the node.
action String The action (uri) associated with the node.
open Boolean Read only. Boolean property that tells if the node is expanded or collapsed (will always return false if there are no child nodes).
icon String Image file to use as icon. Uses default if not specified.
openIcon String Image file to use as the open icon (if child nodes only). Uses default if not specified.
parentNode Reference A reference to the parent node.
childNodes Array Collection of references to all child nodes.

Methods

Name Returns Description
add(oNode, [bNoIdent]) Reference Adds a tree item to the current item. This method takes two argument, the first is the WebFXTreeItem object to add and the second is an optional boolean value, that if specified and set to true will prevent the tree from executing the indent method automatically once the node has been added. This parameter has no effect on calls to the add method before the tree is rendered, but settings this flag when adding nodes after the tree has been rendered will greatly reduce the time needed to complete the operation, this can be quite useful while adding more than one node at a time, but requires that the indent method is manually executed on the top most node affected by the changes afterwards. Returns a reference to the added node.
indent() Void Redraws the traces between nodes and makes sure the tree is properly layed out.
toggle() Void Toggles the expand/collapse.
expand() Void Expands the tree item.
collapse() Void Collapses the tree item.
expandAll() Void Expands the tree item and all sub items recursively.
collapseAll() Void Collapses the tree root and all sub items recursively.
expandChildren() Void Expands all sub items recursively (same as executing expandAll and the collapse).
collapseChildren() Void Collapses all sub items recursively (same as executing collapseAll and the expand).
getNextSibling() Reference Returns a reference to the next sibling.
getPreviousSibling() Reference Returns a reference to the previous sibling.
toString() String Genereates the HTML string needed to render the tree item.

WebFXTree

The WebFXTree object is used to create the actual tree root that can later be populated with tree items. All properties and methods from the WebFXTreeAbstractNode are inherited.

Constructor

new WebFXTree([text], [action], [behavior])
Name Type Description
text String Optional. The text label for the tree root.
action String Optional. The action (uri) associated with the tree root.
behavior String Optional. Name of the behavior to use, check the setBehavior() method for details.
icon String Optional. Image to use as the icon.
openIcon String Optional. Image to use as the open icon.

Properties

Name Type Description
rendered Boolean Flag that indicates whatever or no the tree has been generated and rendered.

Methods

Name Returns Description
getSelected() Reference Returns the id of the selected object, if any.
setBehavior(sBehavior) Void Has to be specified before the tree is created and can be used to change the way the tree behaves, possible values are classic (default) and explorer. Check the usage page for more information about this.
getBehavior() String Returns the name of the behavior used.

WebFXTreeItem

Used to create tree items, can be added (uisng the add method) to a WebFXTree or to another WebFXTreeItem object. All properties and methods from the WebFXTreeAbstractNode are inherited.

Constructor

new WebFXTreeItem([text], [action], [parent], [icon], [openIcon])
Name Type Description
text String Optional. The text label for the tree item.
action String Optional. The action (uri) associated with the tree item.
parent Reference Optional. Reference to an object to witch the node should be added.
icon String Optional. Image to use as the icon.
openIcon String Optional. Image to use as the open icon.

Properties

Name Type Description
None but the inherited ones

Methods

Name Returns Description
getFirst() Reference Returns a reference to the first child node, if any.
getLast() Reference Returns a reference to the last child node, if any.
posted @ 2010-07-20 22:42 .NET JAVA园 阅读(214) 评论(0) 编辑

总写失败的经历,可能会误导大家,也可能会对刚开始学习软件技术的人也会有一些消极的负面的影响,大部分人也会觉得我的开发水平、管理水平很糟糕一样,其实我也说不出来有啥独特的技术,自己总结下来后:“以最快的速度搞定客户的实际工作需要,把项目用最快的速度做好、最稳定高效运行,能经得起长期的考验,大数据量的考验”。

 

   故事的一切前提:

     你是个工作狂,工作拼命,不管是打工还是创业,不管是周末还是春节,你心思都用在工作上,为了把工作做好就算打工你也可能经常搞个通宵,没有这样的拼尽、干劲,几乎什么东西也做不成的,连打工都打不好的人,想独立做项目或者创业,那基本上失败的可能性是90%还要多吧。

 

   我创业时总结了一些开发方面失败的经验:

   01。当你想自己开公司时,做项目需要的东东,不是你自己开公司时才开始准备,而是在你打工的时候就全部提炼好,真正做项目时一个月4-5千元薪资的程序员,一个月有可能啥明显的工作成果也干不出来的,你也不能因为这个把他开除了,你也拿他没办法的,而且你还要指导他怎么怎么做,而且做出来的东西也不太稳定,复用性也比较差,而且还有人员流动的风险,给你留下搞了一半的半摊子项目,让你死去活来,现在开软件公司的老板应该会有比较深的体会。

   02。你需要有个比较稳定可靠的数据库访问层等等,可以提高软件开发速度、减少编码工作量的稳定高效的组件、同时也可以适当的约束你的同事、合作伙伴。

   03。你需要一个万能的管理类软件的后台管理效果,例如菜单的控制管理,里面的页面都怎么做,需要有一整套的固定风格,而且做得也比较漂亮大气、稳定可靠的那种,这样你不管接了什么项目,稍微修改一下就可以在下一个项目里用,见效快不会乱折腾,尽量不要在这方面消耗过多的成本。

   04。你应该有一套稳定高效的后台控制工具,例如用户管理、用户的权限控制,系统的菜单管理、用户的菜单访问权限管理、角色管理等,而且不能有丝毫的错误,稳定得要命,你可以在几分钟内就可以部署好你的管理功能工具,几个小时内就可以把用户的账户权限等全部配置好,想都不用想就可以搞定了。

   05。你还需要一套高效的数据库设计工具,总不能系统需要啥功能就建一个表、做到哪里算到哪里,那你这系统早晚会崩溃的、明显是属于乱搞嘛。

   06。你还需要一个高效的代码生成工具,那些底层的,没有技术含量的代码都不要靠人工写了,人会累会马虎会大意会走神会偷懒,这些都使用代码生成器写就可以了。

   07。你有一整套的成熟的日常工作上遇到的问题如何解决的成熟思路,例如编号序列生成器、参数管理工具、日志管理、数据备份、当然哪些左链接啥的对你来说是小菜一碟就是,想都不用想就可以搞定了。

   08。简单的页面,你可以在半个小时内做得一个bug没有,而且精力旺盛、斗志比较高、身体也强壮一些,否则也吃不消连续的高工作压力下连续工作多天,有上百个功能等着你要实现,你要有足够的心理承受能力,否则会精神分裂或者压抑暴躁。

   09。你有严谨的思维,可以把一个项目分解成几百个小功能点,然后不重复折腾,先后顺序井然的,一个个的,一口气作战把一个个页面、一个个功能都能搞定,每天都搞定10-20个功能,甚至更多,而且就像是玩一样的速度,工作就当成娱乐而不是痛苦。

   10。你能处理非常复杂要求的功能页面的能力,遇到再复杂的功能,你也心不乱、心不慌,估计需要你一天之内就可以搞定吧,Javascript 、ajax 等用得也比较熟悉一些,三下两下就可以调试通过。

   11。你还有几招必杀技,例如有比较技术震撼力的解决思路,解决方法,解决方式,友善的操作页面等等。

   12。你需要有一天能测试出别人程序100-200个错误,能检查出上百个代码不规范,同事可以检查3-5个人的代码,一眼扫过去就能大致知道这个人写程序哪里会有问题,程序还没运行时,你就能说出这个程序会有哪些Bug,哪些安全隐患等等的能力。

   13。你有最高配置的笔记本电脑,电脑要能跟上你的思路,N多的工程瞬间就能编译好,根本不会在编译调试上浪费时间,有熟练的调试能力,三下两下就可以把复杂的功能调试好。

   14。你有大规模可复制粘贴的大量范例程序,可能是你3-5年来一直在完善的例子程序,哪个功能从哪个文件的哪个位置复制粘贴,连想都不用想,瞬间就可以找到复制的区域,我的电脑的ctrl + c, ctrl + v 键盘几乎是磨损得最厉害,我根本不讲什么创造性,1个月搞定10万,客户也满意,你也满意就可以了,何必瞎折腾呢?

   15。说百了,需要“数据库设计规范、编码规范、页面规范、权限架构规范、规范的例子程序、代码生成器”有了这些,再来一个神速的复制粘贴 + 惊人的调试组织能力,严谨的项目拆分、组织、先后顺序安排能力,这个项目就像玩一个搞定了,只不过是一个过程而已,因为是重新开发、有上百上千个功能点所以再神也不可能一天内搞定而已。

  16。客户要的不是高科技,就是那些通俗的日常业务,只是需要你做得越快越好,越好用越好,越省钱越好,越稳定越好、你懂什么设计模式、接口、泛型、委托、代理、工作流、silverlight、WCF、WF、WebService等等一大对狗屁技术还不能能做得界面漂亮一些,你懂什么某个性能的极致优化,还不如把你的项目整体做得最稳定、最可靠、最方便客户操作、整体运行效率高,客户就最满意,而不会偏重与某个细节上,客户更注重的是项目的整体。

  17。客户关心的不是编码、用什么语言、代码质量等等,客户关心的是能否满足他们的需求、能否实现那些最基本的功能,但是你编码太烂,就经不起客户的折腾,人家功能稍微变动一下、逻辑稍微更改一下,你的烂代码就瘫痪了,俗话讲的话,就经不起折腾了,在我眼里,代码再烂能经得起客户的反复折腾而不乱就是好代码。 

 

那你若具备了以上几个要求,那下面的故事就可以开始了。

 

   有一家上海的小型IT公司(10个开发人员内左右吧,估计其中有2个人开发这个项目)承接了杭州一家电子商务公司的B2C网上购物系统,前后搞了3个月,总是远远满足不了客户的实际需求,因为软件系统必须要经得起实战,客户的投资也不小,项目等一天就是损失好几千元,还有跟钱一样重要的是时间成本,机会成本,十几号相关的配套人员就等着这个项目上线运作,前后3个月了也远远满足不了客户的各种需要,客户的运行总监自己也是IT行业软件出身他也看出来要靠这个小软件公司早晚是个死,就下决心叫停这个项目的开发了。

 

   他找我,问我多久能做出来这个项目来?我评估了他们已经做好的功能、程序代码、数据库设计等等,基本上是中等偏下的水平吧,代码有些乱,数据库有些乱,类也乱,分层也乱,我也没耐心去维护那个代码,我就直接跟客户讲,这个公司的水平不怎么高,接下来能把这个项目能做好的希望是渺茫一些,而且他们越做越赔钱而已,开发公司也确实支撑不下去了。

 

   我网上找了一些网上购物的现成的软件,基本上是PHP的多,我是没能力去折腾修改PHP的程序,那估计对我来说是个折磨,我找了一些其他.net开发的项目,也不是很理想,我自己也评估了一下,系统整套的功能做下来估计需要3周-4周,而且接下来都会非常容易维护,系统的稳定性也高一些。

   客户的时间和宝贵,后面还有更大投资在进行中,客户跟我说得很实在他们只肯出10万的软件开发预算,只能有1个月时间,问我是不是愿意帮他们一下?我想了一下,也不好拒绝,正好想买个车子,有10万也差不多了,不够的按揭买个车也不错。

   客户说,我怎么可以相信你,你一个月内可以完整的完成这个项目?我的回答“若我不能按时完成这个项目,我愿意赔偿4万元”,因为我只有这么多存款,其他实在没钱了,那就签一个合同,不能按时完成,就按合同来。

 

   接下来,我大致的时间安排是:

   01:用了一天时间,说服他们的公司的从上到下,是足够可以完成这个项目,让他们彻底相信我的能力。

   02:用了一天时间,把他们现有的系统的功能都了解好,然后把客户的期望值了解好。

   03:用了一天时间,把他们的表结构整理好,把没用的代码删除掉、把没用的层什么的删除掉。

   04:用了三天时间,把他们的系统的错误都修正好,让网上购物程序先跑起来。

   05:用了一天时间,把他们系统的外部广告推广接口实现好。

   06:用了一天时间,把心的SVN服务器架构好,把新域名配置好,把数据库服务器、网站服务器配置好,把后台管权限理工具配置好,把前台购物网站、后台管理网站配置好。

   07:用了五天时间,把前台购物网站全部重新实现好,用户的注册、购物车、订单确认、配送方式、邮费、商品购物、游客购物、 支付宝接口实现等等全不实现好,几乎没有停顿,平均一天10-20个功能实现好,一天2-3个功能页面搞定好。

   08:用了一天时间,给他们展示前台功能,让他们了解项目的进展。

   09:用了一天时间,把他们原有系统里的数据全部导入到新系统里,不用客户重新输入数据了,几百条纪录人家也是输入了很久的。

   10:用了三天时间,把商品的管理、上架设置、价格设置、库存设置、尺码款式设置、产品说明管理等等做好。

   11:用了三天时间,把整个订单的管理、配货、发货、收款、退款、客户服务、评论管理等都做好,平均一天10-20个功能实现,一天平均3-4个页面的速度。

   12:用了一天时间给他们演示系统的功能,其中用了半天时间,部署新的网站,项目成功上线,就等客户验收付款。

 

   其中有几天,心情不好睡懒觉、陪老婆看电影,逛街,写博客吹牛,主要是觉得做网上购物的程序,前途还是比较光明,市场也会比较看好,现在人人都开网店,网上购物也越来越普遍,稍微有钱的公司,有钱的老板,都想按自己的方式来个网上购物网站,投资个10万8万也觉得很正常。

   千些日子,我老婆的师哥,在北京找了个人做一个网上购买书的电子商务网站,砸了个万八的,最后项目失败了,其实你不要觉得做一个B2C的网上购物网站有那么简单,你可以自己做个试验,你真的能用1个月的时间,能做出一个完整的网上购物系统(包括前台、后台)吗?

   我这些年,就连就了一个水平,如何用最快的速度把项目拿下,一个项目拿下了后,我就会休息,寻觅机会,不断完善自己的工具、架构、把积累再巩固一下,等把下一个项目用更极限的时间完成。

 

   只有那些陷入困境的项目,客户很急的项目,有紧迫的时间要求的项目才比较值钱一些,比较刺激,比较挑战极限,我并不是为了炫耀自己,只是想给那些学计算机软件的朋友们一个信心,做软件是可以赚到钱,但是需要你付出很多努力,需要你有很多积累。

   同时也向经常打击我的朋友说一声,我没啥其他能力,只有一个能力就是神速搞定陷入僵局的项目,以最快的速度把软件项目完成,这就是我这些年练就的水平,就只关注了做软件赚钱速度,其他什么都没怎么在乎,你若不服,你可以自己折腾一下看看,网上购物程序,订单管理系统、互联网是时代发展的潮流。

 

   写得乱了一些,希望能对你有所帮助,别人再有需要网上购物程序的,别忘记跟我合作,我这里有成熟的网上购物系统,代码质量高,配套工具也全,一起合作赚钱,还是比较开心的,我们不要跟钱过不去,我是能把事情办成的人,你也有希望从我身上赚到钱,拿我赚到钱的希望是有的,我有你可利用的价值。

   当然我们做出来的软件系统,客户天天在用,为全国的朋友在做服务,也是值得骄傲的事情,很有成就感的事情,当然你连一个月都没用把整套的B2C网站系统都做出来了,那我可以很认真的告诉你,你强,我认输了,我不是你对手,我错了兄弟,你才是真正的软件人才。

 

    机会不是天天都有,1年能碰上这样的机会1-2次就往往就足够了,一个开发人员一年才赚几个钱?累上1-2次,休息个5-6个月,应该也没啥问题,每次项目突击好了,把经验再总结一下,把自己架构中的不足、程序中的不足好好优化一下,把做新项目学到的知识,可以重复利用的模块再优化一下,放入自己的知识库,等下次更好更有油水的项目,在家里等等机会,网上写写文章,让需要的人能 及时搜索到你,能第一个搜索到你,就是在家里喝茶,也有希望钱会找上门来的。

 

     有时候别人会说,吉日你也太能吹牛了,我可以用以下几点来证明一下:

     1:我的大老婆是笔记本电脑、真实的老婆是属于二奶的位置上。

     2:一天处了睡觉、偶尔想想美女外,脑子里全是软件程序,虽然水平不高,但是日常生活里遇到的问题想得足够透彻。

     3:一个技术问题若没能解决,我绝对是饭吃不下,觉睡不着,非把这个问题解决了不可,有些问题可能折磨我三五年,才能想通。

     4:看过N多书、N多技术文章,平时不怎么看娱乐新闻、也不看任何名著、也不看连续剧、生活单调无趣。

     5:10年都超过了,几乎天天是这样的生活,猪也能变成高级程序员了吧,傻瓜也能会写程序了吧?天天琢磨这玩意儿啊。

     6: 今年是大学毕业后的第10年了,还经常想程序想得走火入魔,经常深夜起来写写程序,把自己的思路及时记录下来,每个月至少都会有那么1-2次吧。

 

     什么叫赚钱:

     1个项目,你干了4周,报价2000元,把工作死去活来的做好了,那也叫赚钱。

     1个项目,你干了4周,报价10000元,你把工作死去活来的做好了,那也叫赚钱。

     1个项目,你干了4周,用了2天时间、说服了客户这个事情值10万、用了2天时间把成果展示好、让客户从上到下都满意都认可你所做的工作,最终大家都开心的支付了你10万的辛苦,也叫赚钱。

    

     你今天创业了,你的思路是用在,用4周把活儿干完上,那你是猪了,你思路用在如何让客户相信这个东西值10万上,那你可以经商去了,创业失败的可能性比较小了。这就叫做,会写程序与会经营的区别,你就是用了1天时间完成了,报价1000元?能证明你什么呢?比我厉害30倍吗? 我给你算一下10万元/1000元 = 100倍的收益差距。

posted @ 2010-04-17 16:42 .NET JAVA园 阅读(778) 评论(0) 编辑

现在浏览网页主要用chrome,因为chrome的速度确实快,包括启动速度和加载网页的速度,比ie和ff快得多,不过看评测OPERA的新版本加载网页速度更快,由于没有用过OPERA,不好评价.我在用chrome和FF显示我的html文件的时候,发现它们的结果有所出入,我先不管是什么原因造成的,先hack一下再说,可是以前用过的css hack 都是针对ie,ff,opera,这个chrome和ff该怎么区分呢?试了几个ie,ff的hack方法,都不行,上网搜索,看到很多人说可以用

 @media screen and (-webkit-min-device-pixel-ratio:0) {     body { background-color: blue; }来进行chrome 和ff的css hack,可是我用了没有效果,最后看到一位仁兄的方法很管用,就是使用:

body:nth-of-type(1) a {

  color:red;

}

body:nth-of-type(1)这句是选择第一个body元素。 据说safari和chrome的内核是一样的。目前只有safari 3+ 和 chrome浏览器支持这种选择方式,所以可用来做它们的hack;

posted @ 2010-04-04 23:32 .NET JAVA园 阅读(1763) 评论(2) 编辑

访问级别修饰符决定其他类是否可以访问该类的某个字段或某个方法。

有两种访问控制种类;

1.Top Level(针对类的修饰)

包括public和package-private(不明确指定修饰符,什么都不写,即默认情况)两种修饰符;

2.Member Level(针对成员的修饰)

包括public,private,protect,package-private四种修饰符。

 

对于类的访问控制,public表示被修饰的类对任何地方的类都可见。如果不写访问修饰符,即package-private情况,被修饰类只对该类所属包的类可见。

对于成员的访问控制,public和package-private的定义和类的访问控制完全一样,成员新增了两个访问修饰符分别是private和protect,private表示该成员只能被所属的类访问,protect包括了package-private的可见性,多出了对该类子类的可见性,子类可以在该类的同一个包,也可以在其他包。

JAVA的访问控制看上去还是很简单,但有一点我觉得有点迷惑,就是如果一个类的访问修饰符为package-private(不明确指定修饰符),那么该类的成员比如一个方法的修饰符定义为public有什么意义?因为该类在别的包都不能访问了,那该类的方法肯定也就无法调用了。但是这样定义程序并不报错,因此肯定有其存在的道理。在网上搜索了一下类似的疑问,发现了一个很好例子可以解释这个疑问。

代码
package test;   
public abstract class Test {   
    
public abstract void test();   
    
public static Test getInstance(){   
        
return new SubTest();   
    }   
}   
class SubTest extends Test{   
    @Override  
    
public void test() {   
        System.
out.println("SubTest's test()");   
    }   
}   
测试用代码:   
import test.Test;   
public class Main {   
    
public static void main(String[] args) {   
        Test t 
= Test.getInstance();   
        t.test();   
    }   
}  

 

 这是现在我知道的唯一一种可以让package-private修饰的类的public或protect方法可以被其他包访问的方法,我想这样写是因为可以间接实现让一个子类重写的方法的访问级别较父类的方法降低,因为重写方法降低访问级别是不允许的。这样假设继承或实现了一个public方法,但是可以让其他包无法得知他的方法,除非通过其父类来访问。算是增加了访问控制的灵活性。

 

posted @ 2010-03-17 07:33 .NET JAVA园 阅读(1035) 评论(1) 编辑

需要引入Jquery库

代码:

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    
<title></title>

    
<script src="Public/jquery.js" type="text/javascript"></script>

    
<style type="text/css">
        .tab
        
{
            background-color
: #FAFAFA;
            margin
: 5px 8px;
            padding
: 5px 10px;
        
}
        .tab p span
        
{
            background-color
: #EFEFEF;
            border
: 1px solid #CCCCCC;
            cursor
: pointer;
            margin-right
: 6px;
            padding
: 2px 5px;
        
}
        .tab p span.current
        
{
            background-color
: #FAFAFA;
            border-bottom-color
: #fafafa;
        
}
        .tab p
        
{
            border-bottom
: 1px solid #CCCCCC;
            font-weight
: bold;
            padding
: 0 10px 2px;
        
}
        .tab li
        
{
            border-bottom
: 1px dotted #CCCCCC;
            padding-bottom
: 3px;
            margin
: 5px 0;
        
}
        .tab .mhot, .tab.allhot
        
{
            display
: none;
        
}
    
</style>

    
<script type="text/javascript">
        $(document).ready(
function() {
            $(
".tab span:first").addClass("current"); //为第一个SPAN添加当前效果样式
            $(".tab ul:not(:first)").hide(); //隐藏其它的UL
            $(".tab span").mouseover(function() {
                $(
".tab span").removeClass("current"); //去掉所有SPAN的样式
                $(this).addClass("current");
                $(
".tab ul").hide();
                $(
"." + $(this).attr("id")).fadeIn('slow');
            });
        });
    
</script>
</head>
<body>
    
<div class="tab">
        
<p>
            
<span id="tab1">tab1</span> <span id="tab2">tab2</span> <span id="tab3">tab3</span></p>
        
<ul class="tab1">
            
<li>我和我的祖国</li><li>最爱的地方</li><li>我和我</li></ul>
        
<ul class="tab2">
            
<li>一花一世办</li><li>一草一天堂</li></ul>
        
<ul class="tab3">
            
<li>阿里巴巴</li><li>阿里巴巴</li><li>一草一天堂</li><li>我和我的祖国</li><li>最爱的地方</li></ul>
    
</div>
</body>
</html>
posted @ 2010-03-02 22:44 .NET JAVA园 阅读(877) 评论(5) 编辑
摘要: jQuery对象和DOM对象相互转化 jQuery对象和DOM对象 jQuery对象就是通过jQuery包装DOM对象后产生的对象。jQuery对象是jQuery独有的,其可以使用jQuery里的方法,但是不能使用DOM的方法;例如$("#img").attr("src","test.jpg"); 这里的$("#img")就是jQuery对象; DOM对象就是Javascript固有的一些对象操作。DOM对象能使用Javascript固有的方法,但是不能使用jQuery里的方法。例如:document.getElementById("img").src="test.jpg";这里的document.getElementById("img")就是DOM对象; $("#img").attr("src","test.jpg"); 和document.getElementById("img").src="test.jpg";是等价的,是正确的,但是$("#img").src="test.jpg";或者document.getElementById("img").a阅读全文
posted @ 2010-03-01 23:16 .NET JAVA园 阅读(302) 评论(0) 编辑
摘要: import org.hibernate.cfg.Configuration; import org.hibernate.tool.hbm2ddl.SchemaExport; /** * DESC-根据hibernate.cfg.xml配置文件和相应实体类及其.hbm.xml文件生成对应的数据库表 * 使用步骤: * 1.建立hibernate.cfg.xml配置文件且在数据库url后面指定数据库名称jdbc:mysql://localhost/DB_NAME(该配置文件放在src根目录) * 2.建立好相应的POJO类和对应的.hbm.xml文件(需要hibernate.cfg.xml中配置) * 3.创建数据库:create database DB_NAME; * 4.打开数据库:use DB_NAME; 阅读全文
posted @ 2010-02-28 14:55 .NET JAVA园 阅读(1540) 评论(0) 编辑