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

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

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

    隨筆-39  評論-33  文章-0  trackbacks-0

    利用newxy(新坐標)技術可以不寫一行java代碼實現多項查詢。(在線演示http://www.newxy.net/zh_cn/samples/sample4/demo.jsp)

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

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

    <nlogic:action1/> 標簽應放在<nhtml:form />標簽上面,這兩個標簽針同一個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> 行業</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"> 農、林、牧、漁業</html:option>

    ????????? <html:option value="B"> 采礦業</html:option>

    ????????? <html:option value="C"> 制造業</html:option>

    ??????? </html:select> 作為范例,行業沒全列出。

    ????? </td>

    ??? </tr>

    ??? <tr>

    ????? <td> 企業名稱</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>

    加入標簽<nhtml:button actionId="act1" method="find" value="查 詢"/>,產生查詢銨鈕

    產生的查詢介面如下:


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

    說明:

    • <nhtml:form />action 屬性值為空,是以當前路徑為值??刹榭串a生的靜態頁面。
    • <html:hidden property="_dao" value="dao.default"/>
      其作用是指明由哪個DAO類來處理。默認值是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/>標簽或<input type="hidden" name="_sql" value="......"/>,是因為要在靜態頁面上不顯示這條sql語名,達到安全的目的。 范例靜態頁面上產生的是<input type="hidden" name="_sql" value="_hidden_sql_1">。 其它幾處<nhtml:hidden />作用相同。
    • 而且、或者邏輯關系由 <html:radio property="_lg" value="1">并且</html:radio> <html:radio property="_lg" value="0">或者</html:radio>決定。
      _lg
      是特定的屬性名。
    • 其它查詢項的組合方法與企業名稱行業代碼查詢項的組合方式相同。
      按照例中的組合,_item1的值可行成類似a.code='A',_item2的值可形成類似b.name like '%公司%'。
      必須一組三項,三項用同一屬性名,屬性名以"_item"開頭,后用不同數字區分。
    • 另有組合方式在后序技術文檔中補充,此文檔暫不介紹。

    利用<nlogic:iterate id="" name="" property=""></nlogic:iterate>標簽、<nlogic:navigate/>標簽、<nhtml:TR></nhtml:TR>標簽、<nhtml:javascripts/>標簽、<nhtml:stylesheets/>標簽來分頁顯示查詢結果。
    建義<nhtml:javascripts/>標簽、<nhtml:stylesheets/>標簽兩標簽放在頁首或較前部。如果有javascripts腳本錯本且數據列表沒有光帶, 是因為沒有使用<nhtml:javascripts/>標簽、<nhtml:stylesheets/>標簽。

    <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>

    ?

    下圖是范例查詢結果

    ?

    ?

    范例的完整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新坐標 閱讀(1964) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 黄色一级免费网站| 激情内射亚洲一区二区三区爱妻| 亚洲毛片免费视频| 人妻视频一区二区三区免费| 黄网址在线永久免费观看 | 免费A级毛片av无码| 亚洲无线观看国产精品| 97在线免费观看视频| 亚洲av无码一区二区乱子伦as| 毛片在线全部免费观看| 91在线精品亚洲一区二区| 亚洲最大av资源站无码av网址| 毛片免费全部播放无码| 亚洲黄色免费观看| 最近的免费中文字幕视频| 色偷偷亚洲男人天堂| 亚洲色一色噜一噜噜噜| 日本亚洲免费无线码 | 亚洲无线一二三四区手机| 亚洲av成人片在线观看| 精品国产麻豆免费网站| 国产亚洲福利精品一区二区| 成年女人A毛片免费视频| 亚洲成av人在线视| 日韩精品免费一级视频| 亚洲国产成人久久精品大牛影视| 亚洲国产高清在线一区二区三区| eeuss影院免费92242部| 日本高清免费网站| 亚洲va在线va天堂成人| 免费v片在线观看| 亚洲AV永久无码精品网站在线观看| 婷婷综合缴情亚洲狠狠尤物| 国产中文字幕在线免费观看| 亚洲欧洲视频在线观看| 亚洲国产精品成人一区| 国产自国产自愉自愉免费24区| 蜜臀91精品国产免费观看| 精品无码国产污污污免费网站国产 | 你懂的在线免费观看| 亚洲国产精品综合久久久 |