⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch03s02.html

📁 优秀的java程序开发软件方式与方法,对大家开发程序的时候有指导性帮助
💻 HTML
字号:
<html><head>      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">   <title>2.&nbsp;Counter&#20363;&#23376;&#19982;&#22238;&#36864;&#38190;&#22788;&#29702;</title><link rel="stylesheet" href="html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="Java&#32593;&#32476;&#31243;&#24207;&#21592;&#30475;Continuation"><link rel="up" href="ch03.html" title="Chapter&nbsp;3.&nbsp;Seaside&#26694;&#26550;"><link rel="prev" href="ch03s01.html" title="1.&nbsp;&#23433;&#35013;&#21644;&#21551;&#21160;Seaside"><link rel="next" href="ch03s03.html" title="3.&nbsp;Multi&#20363;&#23376;&#19982;&#23545;&#35937;&#27169;&#22411;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.&nbsp;Counter&#20363;&#23376;&#19982;&#22238;&#36864;&#38190;&#22788;&#29702;</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s01.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;3.&nbsp;Seaside&#26694;&#26550;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch03s03.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e245"></a>2.&nbsp;Counter&#20363;&#23376;&#19982;&#22238;&#36864;&#38190;&#22788;&#29702;</h2></div></div></div><p>&#29616;&#22312;&#24050;&#32463;&#22312;&#36816;&#34892;&#30340;Seaside&#31243;&#24207;&#20013;&#26368;&#31616;&#21333;&#30340;&#33707;&#36807;&#20110;counter&#20102;&#12290;&#21333;&#20987;counter&#38142;&#25509;&#65292;&#25105;&#20204;&#30475;&#21040;&#22914;&#19979;&#39029;&#38754;&#65306;</p><div class="screenshot"><div class="mediaobject"><img src="resources/counter.png"></div></div><p>&#24744;&#21487;&#20197;&#21333;&#20987;++&#21644;&#8212;&#31526;&#21495;&#30475;&#30475;counter&#31243;&#24207;&#30340;&#29992;&#36884;&#12290;&#24456;&#31616;&#21333;&#30340;&#31243;&#24207;&#23545;&#21543;&#65311;&#29616;&#22312;&#25105;&#20204;&#35797;&#35797;&#29992;&#21518;&#36864;&#38190;&#65292;&#20363;&#22914;&#65292;&#22686;&#21152;&#20004;&#27425;&#65292;&#25105;&#20204;&#24471;&#21040;2&#12290;&#36825;&#26102;&#25353;&#21518;&#36864;&#38190;&#22238;&#21040;0&#65292;&#28982;&#21518;&#25353;++&#65292;&#24744;&#30475;&#21040;&#20960;&#65311;3&#36824;&#26159;1&#65311;</p><p>&#24744;&#20250;&#30475;&#21040;1&#12290;&#19968;&#33324;&#30340;&#32593;&#32476;&#31243;&#24207;&#20250;&#25226;counter&#30340;&#20540;&#20648;&#23384;&#22312;session&#20013;&#65292;&#36825;&#26679;&#30340;&#35805;&#20250;&#32473;&#20986;3&#65292;&#19981;&#36807;Seaside&#26159;&#22522;&#20110;continuation&#30340;&#65292;&#25152;&#20197;&#22914;&#26524;&#24744;&#25353;&#22238;&#36864;&#21518;&#20877;&#25552;&#20132;&#35831;&#27714;&#65292;&#37027;&#20040;&#26381;&#21153;&#22120;&#31471;&#20250;&#20808;&#36339;&#22238;&#24403;&#26102;&#30340;&#29366;&#24577;&#20877;&#37325;&#26032;&#22788;&#29702;&#35813;&#35831;&#27714;&#12290;&#36825;&#26679;&#65292;0&#22686;&#21152;&#21518;&#19968;&#23450;&#26159;1&#65292;&#24744;&#27704;&#36828;&#19981;&#20250;&#30475;&#21040;0&#31361;&#28982;&#21464;&#25104;3&#30340;&#24773;&#20917;&#12290;&#21478;&#22806;&#65292;&#22914;&#26524;&#24744;&#22312;&#20004;&#20010;&#31383;&#21475;&#21516;&#26102;&#20351;&#29992;counter&#31243;&#24207;&#65292;&#23427;&#20204;&#20043;&#38388;&#19981;&#20250;&#20114;&#30456;&#24433;&#21709;&#65292;&#36825;&#26159;&#22522;&#20110;cookie&#21644;session&#30340;&#20256;&#32479;&#31243;&#24207;&#26080;&#27861;&#20570;&#21040;&#30340;&#12290;</p><p>&#29616;&#22312;&#25105;&#20204;&#26469;&#30475;&#30475;counter&#31243;&#24207;&#30340;&#28304;&#20195;&#30721;&#12290;&#21333;&#20987;&#39029;&#38754;&#24213;&#37096;&#30340;Toggle Halos&#38142;&#25509;&#65292;&#24744;&#20250;&#30475;&#21040;&#19979;&#38754;&#30340;&#39029;&#38754;&#65306;</p><div class="screenshot"><div class="mediaobject"><img src="resources/counter-halos.png"></div></div><p>&#36825;&#35828;&#26126;0&#21644;&#20004;&#20010;&#38142;&#25509;&#26159;&#19968;&#20010;&#21483;WACounter&#30340;&#37096;&#20214;&#29983;&#25104;&#30340;&#12290;&#25105;&#20204;&#21333;&#20987;&#25203;&#25163;&#22411;&#22270;&#26631;&#23601;&#33021;&#30475;&#21040;&#35813;&#31867;&#30340;&#20195;&#30721;&#65306;</p><div class="screenshot"><div class="mediaobject"><img src="resources/counter-browser.png"></div></div><p>&#22914;&#26524;&#24744;&#26366;&#32463;&#20351;&#29992;&#36807;Squeak&#65292;&#37027;&#20040;&#24744;&#39532;&#19978;&#23601;&#33021;&#35748;&#20986;&#36825;&#20010;&#39029;&#38754;&#26159;&#27169;&#20223;Squeak&#37324;&#30340;system browser&#65288;&#31995;&#32479;&#27983;&#35272;&#22120;&#65289;&#20889;&#30340;&#12290;&#19981;&#38169;&#65292;&#23427;&#30340;&#21151;&#33021;&#21644;&#29992;&#27861;&#37117;&#21644;system browser&#19968;&#27169;&#19968;&#26679;&#65292;&#20063;&#23601;&#26159;&#35828;&#65292;&#19979;&#38754;&#35762;&#30340;&#25805;&#20316;&#21487;&#20197;&#22312;Squeak&#20013;&#21516;&#26679;&#23436;&#25104;&#12290;&#22914;&#26524;&#24744;&#30495;&#30340;&#22312;&#20570;&#24320;&#21457;&#65292;&#37027;&#20040;&#24744;&#32477;&#23545;&#24212;&#35813;&#29992;Squeak&#37324;&#30340;system browser&#12290;&#19981;&#36807;&#20026;&#20102;&#31616;&#21333;&#36215;&#35265;&#65292;&#36825;&#37324;&#25105;&#20204;&#22312;&#27983;&#35272;&#22120;&#20013;&#35762;&#35299;&#21644;&#32534;&#20889;Seaside&#20195;&#30721;&#12290;</p><p>&#25105;&#20204;&#26469;&#30475;&#30475;WACounter&#36825;&#20010;&#31867;&#12290;&#22914;&#19978;&#22270;&#25152;&#31034;&#65292;&#20854;&#23450;&#20041;&#20026;&#65306;</p><pre class="programlisting">WAComponent subclass: #WACounter    instanceVariableNames: 'count'    classVariableNames: ''    poolDictionaries: ''    category: 'Seaside-Examples-Test'</pre><p>Smalltalk&#30340;&#35821;&#27861;&#23545;&#20110;&#20064;&#24815;&#20102;C&#39118;&#26684;&#35821;&#35328;&#30340;&#31243;&#24207;&#21592;&#26469;&#35828;&#30456;&#24403;&#22855;&#24618;&#12290;&#25105;&#26469;&#31616;&#21333;&#35299;&#37322;&#19968;&#19979;&#65292;&#19978;&#38754;&#30340;&#23450;&#20041;&#26159;&#35828;&#65292;WACounter&#26159;WAComponent&#30340;&#23376;&#31867;&#65292;&#23427;&#26377;&#19968;&#20010;instance variable&#65292;&#21483;&#20570;count&#12290;&#23427;&#30340;&#31867;&#21035;&#65288;Category&#65289;&#26159;Seaside-Examples-Test&#65292;&#27880;&#24847;smalltalk&#21644;Java&#19981;&#21516;&#65292;smalltalk&#27809;&#26377;Java&#37324;package&#30340;&#27010;&#24565;&#12290;&#36825;&#37324;&#30340;&#31867;&#21035;&#21482;&#26159;&#27880;&#37322;&#29992;&#30340;&#65307;smalltalk&#35201;&#27714;&#25152;&#26377;&#30340;&#31867;&#19981;&#33021;&#21516;&#21517;&#65292;&#19981;&#31649;&#23427;&#20204;&#26159;&#19981;&#26159;&#22312;&#21516;&#19968;&#20010;category&#20013;&#12290;</p><p>&#26368;&#21491;&#36793;&#19968;&#26639;&#26174;&#31034;WACounter&#26377;5&#20010;method&#65292;&#20998;&#21035;&#26159;count, decrease, increase, initialize&#21644;renderContentOn&#12290;&#20854;&#20013;initialize&#20250;&#22312;&#23545;&#35937;&#21019;&#24314;&#26102;&#35843;&#29992;&#12290;&#21333;&#20987;&#26368;&#21491;&#36793;&#19968;&#26639;&#30340;initialize&#65292;&#25105;&#20204;&#23601;&#20250;&#30475;&#21040;&#20854;&#20195;&#30721;&#65306;</p><pre class="programlisting">initialize    self session registerObjectForBacktracking: self.    count _ 0</pre><p>&#19978;&#38754;&#30340;&#20195;&#30721;&#20889;&#25104;Java&#39118;&#26684;&#22914;&#19979;&#65306;</p><pre class="programlisting">void initialize() {    this.session().registerObjectForBacktracking(this);    count = 0;}</pre><p>&#31532;&#19968;&#21477;&#36890;&#30693;session&#31649;&#29702;&#26412;&#23545;&#35937;&#65292;&#36825;&#26679;&#25105;&#20204;&#30340;WACounter&#23545;&#35937;&#23601;&#20250;&#34987;&#20445;&#23384;&#21040;continuation&#24403;&#20013;&#12290;Seaside&#21487;&#20197;&#21482;&#29992;continuation&#31649;&#29702;&#19968;&#37096;&#20998;&#32780;&#19981;&#26159;&#20840;&#37096;&#23545;&#35937;&#65292;&#36825;&#26159;&#22240;&#20026;&#26377;&#26102;&#20505;&#29992;&#25143;&#22238;&#36864;&#26102;&#65292;&#25105;&#20204;&#24182;&#19981;&#24076;&#26395;&#35753;&#31243;&#24207;&#23436;&#20840;&#20498;&#36864;&#21040;&#24403;&#26102;&#30340;&#29366;&#24577;&#12290;&#20363;&#22914;&#22312;&#32593;&#32476;&#21830;&#24215;&#20013;&#65292;&#21363;&#20351;&#29992;&#25143;&#36830;&#25353;&#22238;&#36864;&#38190;10&#27425;&#65292;&#25105;&#20204;&#20063;&#19981;&#24819;&#35753;&#20182;&#24050;&#32463;&#25918;&#22312;&#8220;&#36141;&#29289;&#31726;&#8221;&#37324;&#30340;&#21830;&#21697;&#31361;&#28982;&#37117;&#19981;&#35265;&#20102;&#12290;&#19968;&#33324;&#26469;&#35828;&#65292;&#26377;&#19994;&#21153;&#24847;&#20041;&#30340;&#23545;&#35937;&#65288;&#29305;&#21035;&#26159;&#28041;&#21450;&#25968;&#25454;&#24211;&#30340;&#23545;&#35937;&#65289;&#19981;&#24212;&#35813;&#29992;continuation&#31649;&#29702;&#65292;&#32780;&#28041;&#21450;&#29992;&#25143;&#30028;&#38754;&#30340;&#23545;&#35937;&#21017;&#24212;&#35813;&#29992;continuation&#31649;&#29702;&#12290;</p><p>&#31532;&#20108;&#21477;&#23558;count&#21021;&#22987;&#20540;&#35774;&#20026;0&#12290;&#25105;&#20204;&#21487;&#20197;&#30475;&#21040;&#35201;&#20351;&#29992;continuation&#20107;&#23454;&#19978;&#38750;&#24120;&#31616;&#21333;&#12290;&#21478;&#22806;&#65292;&#24744;&#20063;&#24212;&#35813;&#27880;&#24847;&#21040;&#22522;&#20110;continuation&#30340;&#26694;&#26550;&#19981;&#38656;&#35201;session&#30340;&#27010;&#24565;&#65292;&#20363;&#22914;WACounter&#20013;&#30340;count&#65292;&#20250;&#33258;&#21160;&#22312;continuation&#20013;&#20445;&#23384;&#36215;&#26469;&#65292;&#25152;&#20197;&#25105;&#20204;&#19981;&#38656;&#35201;&#21478;&#22806;&#25226;&#23427;&#25918;&#21040;&#19968;&#20010;&#29305;&#27530;&#30340;session&#23545;&#35937;&#20013;&#21435;&#12290;</p><p>&#25105;&#20204;&#20877;&#26469;&#30475;&#30475;renderContentOn&#20989;&#25968;&#65292;&#20854;&#20195;&#30721;&#22914;&#19979;&#65306;</p><pre class="programlisting">renderContentOn: html    html heading: count.    html anchorWithAction: [self increase] text: '++'.    html space.    html anchorWithAction: [self decrease] text: '--'</pre><p>&#35813;&#20989;&#25968;&#36127;&#36131;&#29983;&#25104;HTML&#20195;&#30721;&#65292;&#23427;&#25509;&#21463;&#19968;&#20010;&#21442;&#25968;&#65292;html&#12290;&#25972;&#20010;&#20989;&#25968;&#31616;&#21333;&#22320;&#35843;&#29992;html&#30340;&#26041;&#27861;&#65306;heading&#65292;achorWithAction&#21644;space&#12290;Heading&#26041;&#27861;&#29983;&#25104;HTML&#30340;&#26631;&#39064;&#65306;&lt;h1&gt;&lt;/h1&gt;&#12290;&#21516;&#26679;&#30340;&#65292;achorWithAction&#29983;&#25104;&#36229;&#38142;&#25509;&lt;a href=&#8221;&#8230;&#8221;&gt;&lt;/a&gt;&#65292;space&#29983;&#25104;&#31354;&#26684;&amp;nbsp;&#12290;&#27604;&#36739;&#29305;&#21035;&#30340;&#26159;anchorWithAction&#21518;&#38754;&#30340;&#26041;&#25324;&#21495;&#65292;self increase&#21644;self decrease&#65288;&#30456;&#24403;&#19982;this.increase()&#21644;this.decrease()&#65289;&#12290;&#22312;Seaside&#20013;&#65292;&#25105;&#20204;&#25226;&#36229;&#38142;&#25509;&#25152;&#28608;&#27963;&#30340;&#25805;&#20316;&#30452;&#25509;&#25918;&#22312;anchorWithAction&#30340;&#21442;&#25968;&#37324;&#65292;&#32780;&#19981;&#29992;&#20026;&#27599;&#20010;&#36229;&#38142;&#25509;&#24819;&#19968;&#20010;&#29305;&#23450;&#30340;&#21517;&#23383;&#65292;&#20043;&#21518;&#20877;&#26681;&#25454;&#36825;&#20010;&#21517;&#23383;&#20915;&#23450;&#35201;&#36827;&#34892;&#30340;&#25805;&#20316;&#12290;Java&#30340;tapestry&#20063;&#35797;&#22270;&#23436;&#25104;&#21516;&#26679;&#30340;&#20219;&#21153;&#65292;&#19981;&#36807;smalltalk&#28789;&#27963;&#30340;&#35821;&#27861;&#20351;&#24471;Seaside&#38750;&#24120;&#31616;&#27905;&#27969;&#30021;&#12290;</p><p>&#21097;&#19979;&#30340;&#19977;&#20010;&#20989;&#25968;&#65292;count&#65292;increase&#21644;decrease&#37117;&#38750;&#24120;&#31616;&#21333;&#65292;&#25105;&#20204;&#23601;&#19981;&#22312;&#36825;&#37324;&#28010;&#36153;&#31508;&#22696;&#20102;&#65292;&#26377;&#20852;&#36259;&#30340;&#35835;&#32773;&#21487;&#20197;&#33258;&#24049;&#30740;&#31350;&#19968;&#19979;&#12290;</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s01.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch03s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">1.&nbsp;&#23433;&#35013;&#21644;&#21551;&#21160;Seaside&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;3.&nbsp;Multi&#20363;&#23376;&#19982;&#23545;&#35937;&#27169;&#22411;</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -