风人园

弱水三千,只取一瓢,便能解渴;佛法无边,奉行一法,便能得益。
随笔 - 99, 文章 - 181, 评论 - 56, 引用 - 0
数据加载中……

ruby 入门

1、安装及配置
2、HelloWorld

posted @ 2007-05-11 17:14 风人园 阅读(202) | 评论 (0)编辑 收藏

Struts2 flow 配置


1、默认配置
2、别名
3、返回结果

posted @ 2007-05-10 13:12 风人园 阅读(304) | 评论 (0)编辑 收藏

PHP框架

FleaPHP   http://www.fleaphp.org/

posted @ 2007-05-09 20:17 风人园 阅读(264) | 评论 (0)编辑 收藏

RadRails使用参考

利用Radrails开发Ruby on Rails程序入门指南
http://blog.csdn.net/futurelight/archive/2006/09/27/1297526.aspx

详解用radrails调试rails应用程序
http://www.javaeye.com/topic/40548

使用 RadRails 和 Eclipse 可以轻松进行 Ruby on Rails 开发
http://www.ibm.com/developerworks/cn/opensource/os-ecl-radrails/

以上为几个使用参考

posted @ 2007-05-09 20:03 风人园 阅读(979) | 评论 (0)编辑 收藏

Struts2--form设计


1、form的 theme属性

你可以在<s:form>加上theme="simple"属性,然后自已布局form的输出。如:
<s:form action="Login" method="POST" theme="simple">
<table>
<tr>
<td>
User name: <s:textfield name="name" label="User name"/>
</td>
<td>
Password: <s:password name="password" label="Password"/>
</td>
</tr>
</table>
</s:form>

posted @ 2007-05-09 11:13 风人园 阅读(1127) | 评论 (0)编辑 收藏

JSF--ajax4jsf入门示例(repeater)

一、下载
http://labs.jboss.com/jbossajax4jsf/downloads,现在的版本为1.1

·            复制 ajax4jsf.jar and oscache-2.2.jar 到程序的 WEB-INF/lib 文件夹下.
修改web.xml,增加a4j的filter配置

<filter>
          
<display-name>Ajax4jsf Filter</display-name>
          
<filter-name>ajax4jsf</filter-name>
          
<filter-class>org.ajax4jsf.Filter</filter-class>
          
</filter>
          
<filter-mapping>
          
<filter-name>ajax4jsf</filter-name>
          
<servlet-name>Faces Servlet</servlet-name>
          
<dispatcher>REQUEST</dispatcher>
          
<dispatcher>FORWARD</dispatcher>
          
<dispatcher>INCLUDE</dispatcher>
          
</filter-mapping>
</filter>

二、JSP

<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
    
<head>
        
<title>repeater</title>
    
</head>
    
<body>
        
<f:view>
            
<h:form>
                
<h:panelGrid columns="2">

                        
<h:outputText value="Type the Text:" />
                        
<h:inputText value="#{bean.text}">
                                
<a4j:support event="onkeyup" reRender="repeater" />
                        
</h:inputText>

                        
<h:outputText value="Text in the AJAX Response:" />
                        
<h:outputText id="repeater" value="#{bean.text}" />

                
</h:panelGrid>
        
</h:form>

        
</f:view>
    
</body>
</html>
<a4j:support event="onkeyup" reRender="repeater"/>

在这里我们在父标签(<h:inputText>)中添加了一个AJAX 支持. 该支持绑定了JavaScript事件“onkeyup” .因此, 每一次该事件发布给父标签时,我们的程序将发送一个AJAX请求到Server.这意味着我们的受管理的bean将包含该“text” 域中我们输入的最新数据.

<a4j:support> 标签的“reRender” 属性(attribute)定义我们的页面的哪一部分被更新. 在这里,该页面唯一被更新的部位是 <h:outputText> 标签,因为他的ID值和“reRender” 的属性值向匹配. 在一个页面中更新多个元素(elements)也是很简单的:仅仅把他们的IDs放在 “reRender” 属性中就可以了.

三、Bean & faces-config.xml
package com.ivo.a4j.bean;

public class Bean {

    
private String text;

    
public Bean() {
        
//text = "11";
        
//System.out.println("Create");
    }


    
public String getText() {
        
return text;
    }


    
public void setText(String text) {
        
this.text = text;
    }


}

faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>

    
<managed-bean>
        
<managed-bean-name>bean</managed-bean-name>
        
<managed-bean-class>com.ivo.a4j.bean.Bean</managed-bean-class>
        
<managed-bean-scope>request</managed-bean-scope>
    
</managed-bean>

</faces-config>

posted @ 2007-04-27 08:54 风人园 阅读(2139) | 评论 (1)编辑 收藏

JSF--整合spring

使用JSF-Spring整合
一、下载
进官方网站http://jsf-spring.sourceforge.net,下载lib

二、参考quickstart配置相应文件
http://jsf-spring.sourceforge.net/quickstart.shtml
最终配置结果如下
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
    xsi:schemaLocation
="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
<context-param>
        
<param-name>javax.faces.CONFIG_FILES</param-name>
        
<param-value>
            /WEB-INF/classes/faces/faces-config.xml, 
            /WEB-INF/classes/faces/faces-config-beans.xml
        
</param-value>
    
</context-param>
    
<context-param>
        
<param-name>contextConfigLocation</param-name>
        
<param-value>
            classpath*:spring/applicationContext-*.xml
        
</param-value>
    
</context-param>

    
<servlet>
        
<servlet-name>Faces Servlet</servlet-name>
        
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        
<load-on-startup>0</load-on-startup>
    
</servlet>
    
<servlet-mapping>
        
<servlet-name>Faces Servlet</servlet-name>
        
<url-pattern>*.faces</url-pattern>
    
</servlet-mapping>
    
<listener>
        
<listener-class>
            org.springframework.web.context.request.RequestContextListener
        
</listener-class>
    
</listener>
    
<listener>
        
<listener-class>
            org.springframework.web.context.ContextLoaderListener
        
</listener-class>
    
</listener>
    
<listener>
        
<listener-class>de.mindmatters.faces.spring.context.ContextLoaderListener</listener-class>
    
</listener>
        
</web-app>

请注意以上listener的顺序,如果位置不同可能出现找不到在spring中定义的bean。请按以上顺序配置即可。

根据quitstart配置完之后可能还有如下异常:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: de.mindmatters.faces.spring.factory.BeansEvaluationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uiBean': Scope 'request' is not active; nested exception is java.lang.IllegalStateException: No thread-bound request: use RequestContextFilter
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
de.mindmatters.faces.lifecycle.RenderResponsePhase.executePhase(RenderResponsePhase.java:45)
de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37)
de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:166)
de.mindmatters.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:226)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
然后再把这个listener加上
<listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
 </listener>

就ok了。

可选
如果还有问题,在faces-config.xml中添加
<application>
     <variable-resolver>
      org.springframework.web.jsf.DelegatingVariableResolver
     </variable-resolver>
  <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
 </application>

posted @ 2007-04-26 16:18 风人园 阅读(6068) | 评论 (3)编辑 收藏

JSF--Navigate

JSF中最重要的导航设置
一、静态导航
<h:commandButton label="Login" action="login"/>
通过action返回的字符串,然后比较   from-outcome标签值,如果相同,就返回到   to-view-id  制定的页面
注: view ID strings must start with a /.
二、动态导航
<h:commandButton label="Login" action="#{loginController.verifyUser}"/>
根据action中调用的bean方法返回值来确定显示页面
loginController的验证方法
String verifyUser() {

   if (...)

      return "success";

   else

      return "failure";

}


三、高级导航
Redirection
如果你在to-view-id 后 加redirect元素,则JSP容器即中断当前request请求,并发送一个HTTP redirect 请求到client. 
<navigation-case>
   <from-outcome>success</from-outcome>
   <to-view-id>/success.jsp</to-view-id>
   <redirect/>
</navigation-case>

Wildcards(通配符)
<navigation-rule>
   <from-view-id>/secure/*</from-view-id>
   <navigation-case>
      . . .
   </navigation-case>
</navigation-rule>
只要是在/secure/这个目录下的页面都使用这个导航规则。

所有
<from-view-id>/*</from-view-id>

or
<from-view-id>*</from-view-id>

Using from-action
<navigation-case>
  <from-action>#{quiz.answerAction}</from-action>
  <from-outcome>again</from-outcome>
  <to-view-id>/again.jsp</to-view-id>
</navigation-case>
<navigation-case>
  <from-action>#{quiz.startOverAction}</from-action>
  <from-outcome>again</from-outcome>
  <to-view-id>/index.jsp</to-view-id>
</navigation-case>
根据不同的action使用不同的导航规则。

导航算法

The algorithm has three inputs(算法有三个输入):

  • The outcome, that is, the value of an action attribute or the string resulting from the invocation of a method reference. action属性的值或者引用方法的返回结果(字符串类型)

  • The view ID of the current view。当前视图

  • The action, that is, the literal value of the action attribute in the component that triggered the navigation.用以触发导航的组件属性。

The first of two phases is to find the matching navigation-rule, following these steps(第二阶段的第一步就是寻找符合的导航规则).

  • If the outcome is null, return immediately and redisplay the current page.(如果outcome是空,则立刻返回重新显示当前页面)
  • Merge all navigation rules with the same from-view-id value.(合并相同from-view-id的导航规则)
  • Try to find a navigation rule whose from-view-id value matches the view ID exactly. If such a rule exists, take it.
  • Consider all navigation rules whose from-view-id values end with a wildcard suffix, such as secure. For each such rule, check whether the prefix (after removing the *) is identical to the corresponding prefix of the view ID. If there are matching rules, take the one with the longest matching prefix.
  • If there is a rule without a from-view-id, take it.(如果有没有from-view-id的规则,使用)
  • If there is no match at all, redisplay the current page.(如果都没有符合,重新显示当前页面)

The second of two phases is to consider all navigation-case elements in the matching navigation rule (which may consist of several merged navigation-rule elements with matching from-view-id.values).

Follow these steps to find the matching case.

  • If a case has both matching from-outcome and from-action, take it.
  • Otherwise, if a case has matching from-outcome and no from-action, take it.
  • Otherwise, if a case has matching from-action and no from-outcome, take it.
  • Otherwise, if there is a case with neither from-outcome or from-action, take it.
  • If there is no match at all, redisplay the current page.
    Naturally, we recommend that you do not create tricky navigation rules in your own programs. As long as you stay away from wildcards and from-action elements, you won't need to know about the gory details of the navigation algorithm.


 

posted @ 2007-04-26 15:23 风人园 阅读(566) | 评论 (0)编辑 收藏

JSF--Managed Beans

一、beans在 faces-config.xml中的定义
格式如下:

<managed-bean>
   
<managed-bean-name>user</managed-bean-name>
   
<managed-bean-class>com.corejsf.UserBean</managed-bean-class>
   
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
意思:在session中创建了一个user名字的UserBean对象。
在bean定义之后,就可以通过JSF组件来访问Bean的属性。
 如    <h:inputSecret value="#{user.password}"/>,访问userbean的password属性。

二、Message Bundle
自定义资源文件com/corejsf/messages.properties,通过f:loadBundle访问
<f:loadBundle basename="com.corejsf.messages" var="msgs"/>
basename : properties文件的路径
var: 文件定义的message key

com/corejsf/messages_de.properties.
国际化,在默认资源文件的基础上,增加后缀,标识语言类别。

语言默认显示设置
  • You can add a locale attribute to the f:view element, for example   <f:view locale="de">

  • You can set the default and supported locales in WEB-INF/faces-config.xml (or another application configuration resource):

    <faces-config>
    <application>
    <locale-config>
    <default-locale>en</default-locale>
    <supported-locale>de</supported-locale>
    </locale-config>
    </application>
    </faces-config>
    
    三、Backing Beans
    四、Bean Scope
  • Request

    Session
    Application

    五、Configure Bean 
    设置属性值
      <managed-bean>
       <managed-bean-name>user</managed-bean-name>
       <managed-bean-class>com.corejsf.UserBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
          <property-name>name</property-name>
          <value>me</value>
       </managed-property>
       <managed-property>
          <property-name>password</property-name>
          <value>secret</value>
       </managed-property>
    </managed-bean>
    设置null值
    <managed-property>
       <property-name>password</property-name>
       <null-value/>
    </managed-property>

    posted @ 2007-04-26 14:00 风人园 阅读(543) | 评论 (0)编辑 收藏

    JSF-- 入门 First Example

    一、JSF开发环境
       使用myeclipse的功能,添加相关lib到classpath。 或者从sun的官方网站下载相关lib。
    http://java.sun.com/javaee/javaserverfaces/download.html
    二、JSP页面
          index.jsp

    <html>
        
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
        
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

        
    <f:view>
            
    <head>
                
    <title>A Simple JavaServer Faces Application</title>
            
    </head>
            
    <body>
                
    <h:form>
                    
    <h3>Please enter your name and password.</h3>
                    
    <table>
                        
    <tr>
                            
    <td>Name:</td>
                            
    <td><h:inputText value="#{user.name}" /></td>
                        
    </tr>
                        
    <tr>
                            
    <td>Password:</td>
                            
    <td><h:inputSecret value="#{user.password}" /></td>
                        
    </tr>
                    
    </table>
                    
    <p><h:commandButton value="Login" action="login" /></p>
                
    </h:form>
            
    </body>
        
    </f:view>
    </html>


          welcome.jsp

    <html>
        
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
        
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

        
    <f:view>
            
    <head>
                
    <title>A Simple JavaServer Faces Application</title>
            
    </head>
            
    <body>
                
    <h3> Welcome to JavaServer Faces,
                    
    <h:outputText value="#{user.name}" /> !
                
    </h3>
            
    </body>
        
    </f:view>
    </html>


    三、Bean
          UserBean .java
       package com.test.jsf.bean;

    public class UserBean {

     private String name;

     private String password;

     // PROPERTY: name
     public String getName() {
      return name;
     }

     public void setName(String newValue) {
      name = newValue;
     }

     // PROPERTY: password
     public String getPassword() {
      return password;
     }

     public void setPassword(String newValue) {
      password = newValue;
     }
     
     public String check() {
      name = "wxf";
      return "success";
      //return SUCCESS;
     }
    }

    四、faces-config
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config >
     <navigation-rule>
     
        <from-view-id>/login/index.jsp</from-view-id>
        <navigation-case>
           <from-outcome>login</from-outcome>
           <to-view-id>/login/welcome.jsp</to-view-id>
        </navigation-case>
     </navigation-rule>
     
     <managed-bean>
        <managed-bean-name>user</managed-bean-name>
        <managed-bean-class>
           com.test.jsf.bean.UserBean
        </managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
     </managed-bean>

    </faces-config>
    五、web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     <context-param>
      <param-name>javax.faces.CONFIG_FILES</param-name>
      <param-value>/WEB-INF/faces-config.xml</param-value>
     </context-param>

     <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>0</load-on-startup>
     </servlet>
     <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
     </servlet-mapping>
    </web-app>


    六、测试

       http://localhost:8080/jsf/login/index.faces
    注意,调用jsp页面时一定要使用faces,结尾,否则jsf的标签将无法识别

    posted @ 2007-04-26 12:56 风人园 阅读(591) | 评论 (0)编辑 收藏

    仅列出标题
    共10页: First 上一页 2 3 4 5 6 7 8 9 10 下一页