ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1142
1142
EMPFEHLEN
-
28.08.10 12:22 #1NeuerUser Tutorials.de Gastzugang
Hallo zusammen,
ich bin langsam am Verzweifeln, weil ich einfach den Sinn der Aktion nicht verstehe...
Mein Problem:
Es werden Managedbean Methoden aufgerufen (hauptsächlich @PostConstruct), die mit der aktuellen .xhtml seite absolut nichts zu tun haben.
Beispiel:
AddUrl.xhtml
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.prime.com.tr/ui"> <h:body> <div class="categories"> <div class="c-corner-left"> <div class="c-corner-right"> <div class="indent"> <h:form id="urlForm"> <div class="posturlbox"> <h:inputText value="#{addUrlBean.userUrl}" styleClass="posturlinput" id="url" onclick="this.value = ''" /> </div> <p:commandButton styleClass="button" action="#{addUrlBean.addVideo}" value="#{msg.send}" style="float: left;" update="urlForm" /> <div class="addUrlMessage"> <p:message for="url" showSummary="true" showDetail="false" /> </div> </h:form> </div> </div> </div> </div> </h:body> </html>
AddUrlManagedBean.java
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package managedBeans; import entities.UserEntity; import infoBeans.VideoValidationInfo; import javax.ejb.EJB; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.ViewScoped; import sessionBeans.VideoSessionBean; /** * * @author MasterM */ @ManagedBean(name = "addUrlBean") @ViewScoped public class AddUrlManagedBean extends GeneralManagedBean { @EJB VideoSessionBean videoSessionBean; private String userUrl = "YouTube URL"; @ManagedProperty("#{loginBean}") LoginManagedBean loginMB; /** Creates a new instance of AddUrlManagedBean */ public AddUrlManagedBean() { } public void addVideo() { UserEntity sessionUser = loginMB.getSessionUser(); if (sessionUser == null) { informUser(FacesMessage.SEVERITY_WARN, "log_in_or_crate_new_account", "log_in_or_crate_new_account_detail", "urlForm:url"); } else { int validationId = videoSessionBean.validateVideo(userUrl); if (validationId == VideoValidationInfo.VIDEO_IS_OK) { videoSessionBean.addVideo(sessionUser, userUrl); informUser(FacesMessage.SEVERITY_INFO, "video_create_success", "video_create_success_detail", "urlForm:url"); } else if (validationId == VideoValidationInfo.URL_IS_EMPTY) { informUser(FacesMessage.SEVERITY_ERROR, "url_is_empty", "url_is_empty_detail", "urlForm:url"); } else if (validationId == VideoValidationInfo.URL_SYNTAX_WRONG) { informUser(FacesMessage.SEVERITY_ERROR, "url_syntax_wrong", "url_syntax_wrong_detail", "urlForm:url"); } else if (validationId == VideoValidationInfo.VIDEO_NOT_EXIST) { informUser(FacesMessage.SEVERITY_ERROR, "video_not_exist", "video_not_exist_detail", "urlForm:url"); } else if (validationId == VideoValidationInfo.VIDEO_ALREADY_EXIST) { informUser(FacesMessage.SEVERITY_ERROR, "video_already_exist", "video_already_exist_detail", "urlForm:url"); } else if (validationId == VideoValidationInfo.VIDEO_ID_LENGTH_WRONG) { informUser(FacesMessage.SEVERITY_ERROR, "video_id_length_wrong", "video_id_length_wrongdetail", "urlForm:url"); } } userUrl = ""; } public String getUserUrl() { return userUrl; } public void setUserUrl(String userUrl) { this.userUrl = userUrl; } public LoginManagedBean getLoginMB() { return loginMB; } public void setLoginMB(LoginManagedBean loginMB) { this.loginMB = loginMB; } }
Das komische...
Wenn ich nun in mein CommandButton ausführe, funktioniert zwar alles, jedoch ruft es ebenfalls noch einen @PostConstruct von einer ganz anderen ManagedBean auf und zwar:
UserProfileVideoManagedBean.java
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package managedBeans; import entities.VideoEntity; import enums.VideoStateEnum; import infoBeans.PagingInfo; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.bean.ViewScoped; import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; import sessionBeans.VideoSessionBean; import javax.faces.bean.ManagedProperty; /** * * @author Turk */ @ManagedBean(name = "userProfileVideoBean") @RequestScoped public class UserProfileVideoManagedBean extends GeneralManagedBean { @EJB VideoSessionBean videoSessionBean; private List<VideoEntity> uncheckedUserVideos; private List<VideoEntity> checkedUserVideos; private List<VideoEntity> closedUserVideos; private boolean existUncheckedUserVideos; private boolean existCheckedUserVideos; private boolean existClosedUserVideos; private String sortBy; @ManagedProperty("#{loginBean}") LoginManagedBean loginMB; /** Creates a new instance of UserProfileVideoManagedBean */ public UserProfileVideoManagedBean() { this.existCheckedUserVideos = true; this.existClosedUserVideos = true; this.existUncheckedUserVideos = true; } @PostConstruct public void initProfilVideoState() { System.out.println("PostConstruct: UserProfileVideoMB - RequestScoped"); try { Long userId = this.loginMB.getSessionUser().getId(); uncheckedUserVideos = videoSessionBean.getVideosByStateAndUser(VideoStateEnum.UNCHECKED, userId, PagingInfo.VIDEOS_START_PAGE); if (this.uncheckedUserVideos.isEmpty()) { this.existUncheckedUserVideos = false; } checkedUserVideos = videoSessionBean.getVideosByStateAndUser(VideoStateEnum.OK, userId, PagingInfo.VIDEOS_START_PAGE); if (this.checkedUserVideos.isEmpty()) { this.existCheckedUserVideos = false; } closedUserVideos = videoSessionBean.getVideosByStateAndUser(VideoStateEnum.NOT_OK, userId, PagingInfo.VIDEOS_START_PAGE); if (this.closedUserVideos.isEmpty()) { this.existClosedUserVideos = false; } } catch (Exception e) { } return; } .... und die dazugehörigen Getter-Setter }
Wie kann das nur sein? Was mich zusätzlich wundert ist, dass wenn ich per navigation-rule auf eine andere Seite wechsel, er noch einmal der PostConstruct der alten ManagedBean aufruft.
Es macht einfach keinen Sinn
----------------------------------------------
Primfaces 2.1
Glassfish v3
jsf 2.0
Ejb 3.1
JPA - Toplink
Netbeans
Ähnliche Themen
-
Qt: alle Subklassen sollen mit statischer Methode aufgerufen werden
Von Orbit im Forum C/C++Antworten: 4Letzter Beitrag: 04.08.09, 13:44 -
nach onload im body kann kein 2.script aufgerufen werden
Von goodie im Forum Javascript & AjaxAntworten: 1Letzter Beitrag: 26.06.08, 10:16 -
Durch imagecreatefromjpeg() kann Seite nicht mehr aufgerufen werden
Von Experience1986 im Forum PHPAntworten: 24Letzter Beitrag: 27.05.06, 18:33 -
index.php kann plötzlich nicht mehr aufgerufen werden
Von Gyrim im Forum PHPAntworten: 2Letzter Beitrag: 28.06.05, 14:28 -
Seite kann nicht aufgerufen werden
Von uni im Forum HTML & XHTMLAntworten: 7Letzter Beitrag: 21.01.03, 21:41





Zitieren
Login




