Changeset 6043 for trunk

Show
Ignore:
Timestamp:
11/03/11 17:44:07 (7 months ago)
Author:
mtld
Message:

extended cdi sample

Location:
trunk/pustefix-samples/pustefix-cditest/src/main
Files:
3 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/pustefix-samples/pustefix-cditest/src/main/java/org/pustefixframework/example/cditest/RegistrationHandler.java

    r6020 r6043  
    1818package org.pustefixframework.example.cditest; 
    1919 
    20 import org.springframework.beans.factory.annotation.Autowired; 
     20import javax.inject.Inject; 
    2121 
    2222import de.schlund.pfixcore.generator.IHandler; 
     
    3131        Registration registration = (Registration)wrapper; 
    3232        user.setName(registration.getUsername()); 
     33        user.setPassword(registration.getPassword()); 
     34        boolean ok = user.register(); 
     35        System.out.println("OK: "+ok); 
     36        if(!ok) { 
     37            registration.addSCodeUsername(StatusCodes.FAILURE); 
     38        } 
    3339    } 
    3440 
    3541    public boolean isActive(Context context) throws Exception { 
    36         return user.getName() == null; 
     42        return !user.isRegistered(); 
    3743    } 
    3844 
    3945    public boolean needsData(Context context) throws Exception { 
    40         return user.getName() == null; 
     46        return !user.isRegistered(); 
    4147    } 
    4248 
     
    5056    } 
    5157     
    52     @Autowired 
     58    @Inject 
    5359    public void setUser(User user) { 
    5460        this.user = user; 
  • trunk/pustefix-samples/pustefix-cditest/src/main/java/org/pustefixframework/example/cditest/ResultState.java

    r6020 r6043  
    11package org.pustefixframework.example.cditest; 
    22 
    3 import org.springframework.beans.factory.annotation.Autowired; 
     3import javax.inject.Inject; 
    44 
    55import de.schlund.pfixcore.workflow.Context; 
     
    1616    } 
    1717  
    18     @Autowired 
     18    @Inject 
    1919    public void setUser(User user) { 
    2020        this.user = user; 
  • trunk/pustefix-samples/pustefix-cditest/src/main/java/org/pustefixframework/example/cditest/User.java

    r6020 r6043  
    2121 
    2222import javax.enterprise.context.SessionScoped; 
     23import javax.inject.Inject; 
    2324import javax.inject.Named; 
    2425 
     
    2829     
    2930    private static final long serialVersionUID = -5836404564337831979L; 
     31 
     32    @Inject 
     33    private UserRegistry userRegistry; 
    3034     
    3135    private String name; 
    3236    private String password; 
    33  
     37    private boolean registered; 
     38     
    3439    public String getName() { 
    3540        return name; 
     
    4752        this.password = password; 
    4853    } 
    49  
     54     
     55    public boolean register() { 
     56        registered = userRegistry.register(this); 
     57        return registered; 
     58    } 
     59     
     60    public boolean isRegistered() { 
     61        return registered; 
     62    } 
     63     
    5064} 
  • trunk/pustefix-samples/pustefix-cditest/src/main/webapp/WEB-INF/spring.xml

    r6020 r6043  
    99  <context:annotation-config/> 
    1010 
     11    
     12  <bean id="pwdcheck" class="org.pustefixframework.example.PasswordCheckService"> 
     13    <property name="strength" value="1"/> 
     14  </bean> 
     15   
    1116</beans> 
  • trunk/pustefix-samples/pustefix-cditest/src/main/webapp/dyntxt/statuscodeinfo.xml

    r6020 r6043  
    55                                    http://www.pustefix-framework.org/2008/namespace/statuscodeinfo.xsd"> 
    66 
    7   <statuscodes class="org.pustefixframework.example.numberguess.StatusCodes"> 
     7  <statuscodes class="org.pustefixframework.example.cditest.StatusCodes"> 
    88    <file>statusmessages.xml</file> 
    99  </statuscodes> 
  • trunk/pustefix-samples/pustefix-cditest/src/main/webapp/dyntxt/statusmessages.xml

    r6020 r6043  
    44  <part name="success"> 
    55    <theme name="default"> 
    6       Congratulations, you guessed right!!! 
     6      Registration succeeded. 
    77    </theme> 
    88  </part> 
     
    1010  <part name="failure"> 
    1111    <theme name="default"> 
    12       Sorry, that's wrong, expected number was <pfx:argref pos="1"/>. 
     12      Registration failed. 
    1313    </theme> 
    1414  </part>