<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-39  評(píng)論-33  文章-0  trackbacks-0

    利用newxy(新坐標(biāo))技術(shù)可以不寫(xiě)一行java代碼實(shí)現(xiàn)多項(xiàng)查詢。(在線演示http://www.newxy.net/zh_cn/samples/sample4/demo.jsp)

    • newxy( 新坐標(biāo))多項(xiàng)查詢利用了NQL查詢類(lèi)。
    • newxy( 新坐標(biāo))多項(xiàng)查詢用到三個(gè)標(biāo)簽,<nlogic:action1><nlogic:action2><nhtml:form /><nhtml:button />
    • <nhtml:form />標(biāo)簽內(nèi)不要用 submit之類(lèi)的標(biāo)簽,如<html:submit value=""></html:submit><input type="submit" value=""/>, 取而代之的是<nhtml:button actionId="" method="find" />
    • <nhtml:button actionId="" method="find" /> 不一定要放到<nhtml:form />標(biāo)簽內(nèi)。

    范例對(duì)行業(yè)表、企業(yè)表聯(lián)表查詢,查詢的最基本條件是 企業(yè)表的行業(yè)代碼字段值等于行業(yè)表某條主關(guān)鍵字段值。就是:
    ????enterprise.industry_code=industry.code
    用戶所選擇查詢條件與基本條件是 and 關(guān)系。根據(jù)這樣的前提構(gòu)成的最基本查詢語(yǔ)句:
    ????select a.industry,b.* from industry a,enterprise b where{a.code=b.industry_code}
    newxy(
    新坐標(biāo))將為此創(chuàng)建NQL實(shí)例:nql=new NQL(dao,"select a.industry,b.* from industry a,enterprise b where{a.code=b.industry_code}");
    注意:where后緊跟的是大括號(hào){}
    為了讓理解方便,范例中實(shí)際是行業(yè)大類(lèi)述為行業(yè)代碼

    <nlogic:action1/> 標(biāo)簽應(yīng)放在<nhtml:form />標(biāo)簽上面,這兩個(gè)標(biāo)簽針同一個(gè)formBean,因此屬性formName值相同,在此formName="enterprise"

    <nlogic:action1 id="act1" formName="enterprise"/>

    <nhtml:form action=""? formName="enterprise">

    ? <html:hidden property="_dao" value="dao.default"/>

    ? <nhtml:hidden property="_sql"

    ????? value=" select a.industry,b.* from industry as a,enterprise as b where{a.code=b.industry_code} "/>

    ? <table border="1">

    ??? <tr>

    ????? <td> 邏輯</td>

    ????? <td>

    ??????? <html:radio property="lg" value="1"> 并且</html:radio>

    ??????? <html:radio property="lg" value="0"> 或者</html:radio>

    ????? </td>

    ??? </tr>

    ??? <tr>

    ????? <td> 行業(yè)</td>

    ????? <td> 等于</td>

    ????? <td>

    ??????? <nhtml:hidden property="_item1" value="a.code"/>

    ??????? <html:hidden property="_item1" value="="/>

    ??????? <html:select property="_item1">

    ????????? <html:option value=""></html:option>

    ????????? <html:option value="A"> 農(nóng)、林、牧、漁業(yè)</html:option>

    ????????? <html:option value="B"> 采礦業(yè)</html:option>

    ????????? <html:option value="C"> 制造業(yè)</html:option>

    ??????? </html:select> 作為范例,行業(yè)沒(méi)全列出。

    ????? </td>

    ??? </tr>

    ??? <tr>

    ????? <td> 企業(yè)名稱</td>

    ????? <html:hidden property="_item2" value="b.name"/>

    ????? <td>

    ??????? <html:select property="_item2">

    ????????? <html:option value=""></html:option>

    ????????? <html:option value="="> 等于</html:option>

    ????????? <html:option value="like"> 包含</html:option>

    ??????? </html:select>

    ????? </td>

    ?? ???<td>

    ??????? <html:text property="_item2">

    ??????? </html:text>

    ????? </td>

    ??? </tr>

    ? </table>

    </nhtml:form>

    加入標(biāo)簽<nhtml:button actionId="act1" method="find" value="查 詢"/>,產(chǎn)生查詢銨鈕

    產(chǎn)生的查詢介面如下:


    如果想知道行成的sql語(yǔ)句,可以用struts標(biāo)簽:<bean:write name="enterprise" property="_sql"/>

    說(shuō)明:

    • <nhtml:form />action 屬性值為空,是以當(dāng)前路徑為值。可查看產(chǎn)生的靜態(tài)頁(yè)面。
    • <html:hidden property="_dao" value="dao.default"/>
      其作用是指明由哪個(gè)DAO類(lèi)來(lái)處理。默認(rèn)值是dao.default,此處可以不用,只為演示。"_dao"是特定的屬性名
    • <nhtml:hidden property="_sql" value="select a.industry,b.* from industry as a,enterprise as b where{a.code=b.industry_code}"/>
      在此不用struts<html:hidden/>標(biāo)簽或<input type="hidden" name="_sql" value="......"/>,是因?yàn)橐陟o態(tài)頁(yè)面上不顯示這條sql語(yǔ)名,達(dá)到安全的目的。 范例靜態(tài)頁(yè)面上產(chǎn)生的是<input type="hidden" name="_sql" value="_hidden_sql_1">。 其它幾處<nhtml:hidden />作用相同。
    • 而且、或者邏輯關(guān)系由 <html:radio property="_lg" value="1">并且</html:radio> <html:radio property="_lg" value="0">或者</html:radio>決定。
      _lg
      是特定的屬性名
    • 其它查詢項(xiàng)的組合方法與企業(yè)名稱行業(yè)代碼查詢項(xiàng)的組合方式相同。
      按照例中的組合,_item1的值可行成類(lèi)似a.code='A'_item2的值可形成類(lèi)似b.name like '%公司%'
      必須一組三項(xiàng),三項(xiàng)用同一屬性名,屬性名以"_item"開(kāi)頭,后用不同數(shù)字區(qū)分。
    • 另有組合方式在后序技術(shù)文檔中補(bǔ)充,此文檔暫不介紹。

    利用<nlogic:iterate id="" name="" property=""></nlogic:iterate>標(biāo)簽、<nlogic:navigate/>標(biāo)簽、<nhtml:TR></nhtml:TR>標(biāo)簽、<nhtml:javascripts/>標(biāo)簽、<nhtml:stylesheets/>標(biāo)簽來(lái)分頁(yè)顯示查詢結(jié)果。
    建義<nhtml:javascripts/>標(biāo)簽、<nhtml:stylesheets/>標(biāo)簽兩標(biāo)簽放在頁(yè)首或較前部。如果有javascripts腳本錯(cuò)本且數(shù)據(jù)列表沒(méi)有光帶, 是因?yàn)闆](méi)有使用<nhtml:javascripts/>標(biāo)簽、<nhtml:stylesheets/>標(biāo)簽。

    <nhtml:javascripts/>

    <nhtml:stylesheets/>

    <logic:notEmpty name="enterprise" property="_coll">

    ? <table>

    ? <nlogic:iterate id="rec" name="enterprise" property="_coll">

    ??? <nhtml:TR>

    ????? <td>1</td>

    ????? <td><bean:write name="rec" property="industry"/></td>

    ????? <td><bean:write name="rec" property="name"/></td>

    ??? </nhtml:TR>

    ? </nlogic:iterate>

    ? </table>

    </logic:notEmpty>

    ?

    下圖是范例查詢結(jié)果

    ?

    ?

    范例的完整jsp代碼如下:



    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

    <%@ taglib uri="/WEB-INF/newxy-html.tld" prefix="nhtml"%>
    <%@ taglib uri="/WEB-INF/newxy-logic.tld" prefix="nlogic"%>
    <%@ taglib uri="/WEB-INF/newxy-bean.tld" prefix="nbean"%>
    <nhtml:javascripts/>
    <nhtml:stylesheets/>

    <nlogic:action1 id="actResource" formName="resources"/>

    <nbean:formBean name="resources" sql="select resource_id,resName from resources"/>

    <logic:present name="resources">
    ? <logic:notEmpty name="resources" property="_coll">
    <div style="padding-left:40px">
    <table border="0" width="700">
    ? <tr>
    ??? <td valign="top">
    ????? <table border="0" width="300">
    ??????? <tr>
    ????????? <td style="font-size:14px"><b>資源下載</b></td>
    ??????? </tr>
    ??????? <nlogic:iterate id="rec" name="resources" property="_coll">
    ????????? <nhtml:TR onclick="edit(actResource);">
    ??????????? <td style="cursor:hand">
    ????????????? <bean:write name="rec" property="resName"/>
    ??????????? </td>
    ????????? </nhtml:TR>
    ??????? </nlogic:iterate>
    ????? </table>
    ??? </td>
    ??? <bean:define id="_id" name="resources" property="resource_id">
    ??? </bean:define>
    ??? <nbean:formBean cache="false" refresh="true" name="resource" sql="select * from resources where resource_id="/>
    ??? <td valign="top">
    ????? <table border="0" width="400">
    ??????? <tr>
    ????????? <td><b>資源名:</b></td><td>&nbsp;<bean:write name="resource" property="resName"/></td>
    ??????? </tr>
    ??????? <tr>
    ????????? <td><b>版本:</b></td><td>&nbsp;<bean:write name="resource" property="ver"/></td>
    ??????? </tr>
    ??????? <tr>
    ????????? <td><b>備注:</b></td><td>&nbsp;<p style="width:300px"><bean:write name="resource" property="remark"/></p></td>
    ??????? </tr>
    ??????? <tr>
    ????????? <td><b>上傳日期:</b></td><td>&nbsp;<bean:write name="resource" property="uploadDate" format="yyyy年MM月dd日"/></td>
    ??????? </tr>
    ??????? <tr>
    ????????? <td colspan="2">&nbsp;<html:link target="_blank" page="/download?name=resource&property=content&fileName=resName">下載</html:link></td>
    ??????? </tr>
    ????? </table>
    ??? </td>
    ? </tr>
    </table>
    </div>
    ? </logic:notEmpty>
    </logic:present>

    posted on 2007-03-08 00:18 newxy新坐標(biāo) 閱讀(1965) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 七次郎成人免费线路视频| 日韩成人免费视频播放| 鲁死你资源站亚洲av| 亚洲黄色免费在线观看| 亚洲乱码国产一区网址| 夜夜嘿视频免费看| 又大又硬又爽又粗又快的视频免费| 黄色视频在线免费观看| 色欲色欲天天天www亚洲伊| 亚洲中文字幕久久精品蜜桃| 亚洲黄色在线观看网站| 久久精品国产精品亚洲精品| 亚洲男人在线无码视频| 日韩精品成人亚洲专区| 日本不卡免费新一二三区| 成年女性特黄午夜视频免费看| 麻花传媒剧在线mv免费观看| 久久午夜夜伦鲁鲁片免费无码 | 国产麻豆视频免费观看| 日韩精品无码免费一区二区三区 | 日韩a级毛片免费观看| 西西大胆无码视频免费| 国产四虎免费精品视频| 亚洲综合免费视频| 最近的中文字幕大全免费8 | 亚洲国产成人精品久久| 亚洲视频在线播放| 亚洲小视频在线观看| 久久精品国产亚洲AV麻豆不卡| 亚洲精品V欧洲精品V日韩精品| 亚洲国产a∨无码中文777| 久久久影院亚洲精品| 久久精品亚洲一区二区三区浴池| 亚洲国产综合91精品麻豆| 亚洲视屏在线观看| 亚洲人成在线精品| 最新国产精品亚洲| 国产精品亚洲精品日韩动图| 全部一级一级毛片免费看| CAOPORN国产精品免费视频| 国产精品美女久久久免费|