[JBoss Seam] - a problem with jBpm in Seam
by mnrz
Hi
I am trying to change registration example in order to work with JBpm. but at the first page it is a button with action #"{register.register}"
I define in pageflow if the user already exists tnot change the current page and if not, go to next page, but It calls action register first and it check the database and because user is not exist then that action persist the data into the database and that action is calling again and in the second time, that user already persisted so the current page staty intact and a message will be displayed.
here is pageflow definition file:
| <pageflow-definition name="SeamPracticePageFlow">
|
| <start-page name="start" view-id="/pages/register.jsp">
| <transition name="register" to="checkUser" />
| </start-page>
|
| <decision name="checkUser" expression="#{register.alreadyExists}" >
| <transition name="false" to="registered" >
| <action expression="#{register.register}" />
| </transition>
| <transition name="true" to="start" />
| </decision>
|
| <page name="registered" view-id="/pages/registered.jsp">
| <redirect/>
| <transition name="welcomeMessage" to="listMessage" >
| <action expression="/pages/messages.seam" />
| </transition>
| </page>
|
| <page name="listMessage" view-id="/pages/messages.jsp">
| <redirect/>
| <end-conversation/>
| </page>
|
| </pageflow-definition>
|
and jsp file:
| <f:view>
| <h:form>
| <table border="0">
| <s:validateAll>
| <tr>
| <td>Username</td>
| <td><h:inputText value="#{user.username}" required="true"/></td>
| </tr>
| <tr>
| <td>Full Name</td>
| <td><h:inputText value="#{user.fullName}" required="true"/></td>
| </tr>
| <tr>
| <td>Password</td>
| <td><h:inputSecret value="#{user.password}" required="true"/></td>
| </tr>
| </s:validateAll>
| </table>
| <h:messages/>
| <h:commandButton type="submit" value="Register" action="#{register.register}"/>
| </h:form>
| </f:view>
|
and the action:
| @Create
| @Begin(join=true,pageflow="SeamPracticePageFlow")
| public void register() {
| try {
| if(isAlreadyExists()) {
| userNotExists = false;
| em.persist(user);
| logger.info("user #{user.username} registered.");
| //return "/pages/registered.jsp";
| }else {
| logger.info("user #{user.username} already registered.");
| userNotExists = true;
| }
| } catch (Exception e) {
| e.printStackTrace();
| }
|
| }
|
| public boolean isUserNotExists() {
| return userNotExists;
| }
|
| public boolean isAlreadyExists() {
| try {
| List registered = em.createQuery("select username from User where username = :u")
| .setParameter("u",user.getUsername())
| .getResultList();
| if(registered == null || registered.size() == 0) {
| return true;
| }else {
| FacesMessages.instance().add("user #{user.username} already exists.");
| return false;
| }
| }catch(Exception e) {
| e.printStackTrace();
| }
| FacesMessages.instance().add("something's wrong...");
| return false;
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981675#3981675
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981675
19 years, 6 months
[JBoss Seam] - @DataModel and @In attribute
by sherkan777
Hi!
I I've application based on Seam + Facelets and my problem is, how to reload page and reload collection content?
I've menu component (Statefull bean @DataModel), and content page, also @DataModel collection and global variable selectedCategory;
Example:
Menu: (Treees, Buildings, ...)
When i Click on trees i want set new value of selectedCategory send it to my SESSION SCOPE, and in content bean pull it, fill my choosenCategory; collection of new variables and reload my page with content of all trees.
When i choose trees once (first time)
@In(scope=ScopeType.SESSION, value="currentCategory", required=false)
private String currentCategory;
everithink works fine, currentCategory is set by @in attribute and trees are loaded from DB, but if I choose again it doesn't works?
currentCategory is changed but choosenCategory is not reloaded.
If i change stateful bean scope.SESSION of collection (TREES) to Conversation it works fine! For each conversation page is realoaded, but it's not good idea.
I don't want to have xxx convesations.
What should I do to change my currentCategory and reload content of my
@DataModel
choosenCategory;
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981665#3981665
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981665
19 years, 6 months