Skip to content

Commit be71e41

Browse files
committed
Merge pull request #4 from carlosvasquez/master
FIX: Arreglando la perdida de página al momento de hacer login
2 parents 9d322ec + 527ee02 commit be71e41

File tree

5 files changed

+75
-17
lines changed

5 files changed

+75
-17
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.devdom</groupId>
55
<artifactId>developer-influencer</artifactId>
6-
<version>1.4</version>
6+
<version>1.4.1</version>
77
<packaging>war</packaging>
88
<name>developer-influencer</name>
99
<organization>

src/main/java/org/devdom/tracker/bean/AdministrationController.java

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import javax.faces.component.UIViewRoot;
88
import javax.faces.context.ExternalContext;
99
import javax.faces.context.FacesContext;
10+
import javax.servlet.http.HttpServletRequest;
11+
import javax.servlet.http.HttpSession;
1012
import org.primefaces.util.Constants;
1113

1214
/**
@@ -18,10 +20,23 @@
1820
public class AdministrationController implements Serializable {
1921

2022
private static final long serialVersionUID = 1L;
21-
private FacesContext facesContext = null;
22-
private UIViewRoot uiRoot = null;
23-
private String viewId = "";
23+
private FacesContext facesContext;
24+
private ExternalContext externalContext;
25+
private UIViewRoot uiRoot;
26+
private String viewId;
27+
private final HttpSession session;
2428

29+
public AdministrationController(HttpServletRequest request) {
30+
session = request.getSession();
31+
}
32+
33+
public AdministrationController(){
34+
facesContext = FacesContext.getCurrentInstance();
35+
externalContext = facesContext.getExternalContext();
36+
session = (HttpSession) externalContext.getSession(true);
37+
uiRoot = facesContext.getViewRoot();
38+
viewId = uiRoot.getViewId();
39+
}
2540
/**
2641
* Retornar la versión de JSF que se utiliza en el proyecto
2742
* @return
@@ -45,7 +60,6 @@ public String getPrimefacesVersion(){
4560
* @return
4661
*/
4762
public String getActiveGroupId(){
48-
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
4963
Map<String,String> request = externalContext.getRequestParameterMap();
5064
return (request.get("g")!=null)?request.get("g"):"";
5165

@@ -56,9 +70,6 @@ public String getActiveGroupId(){
5670
* @return
5771
*/
5872
public int getActiveIndex(){
59-
facesContext = FacesContext.getCurrentInstance();
60-
uiRoot = facesContext.getViewRoot();
61-
viewId = uiRoot.getViewId();
6273

6374
switch(viewId){
6475
case "/groupTop20.xhtml" : return 0;
@@ -68,4 +79,24 @@ public int getActiveIndex(){
6879
default : return 0;
6980
}
7081
}
82+
83+
public String getLastViewId(){
84+
String lastViewID = (String) session.getAttribute("lastViewID");
85+
String paramString = "";
86+
String sep="?";
87+
String[] localParams = {"pid","groupId","g"};
88+
89+
for(String param : localParams){
90+
if(session.getAttribute(param)!=null){
91+
paramString+=sep+param+"="+session.getAttribute(param);
92+
sep="&";
93+
}
94+
}
95+
96+
return lastViewID+paramString;
97+
}
98+
99+
public String getViewId(){
100+
return viewId;
101+
}
71102
}

src/main/java/org/devdom/tracker/bean/FacebookController.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.devdom.tracker.bean;
22

33
import java.io.Serializable;
4+
import java.util.Map;
45
import javax.faces.bean.ManagedBean;
56
import javax.faces.bean.RequestScoped;
7+
import javax.faces.context.ExternalContext;
68
import javax.faces.context.FacesContext;
79
import javax.servlet.http.HttpSession;
810
import org.devdom.tracker.model.dto.FacebookProfile;
@@ -17,16 +19,18 @@ public class FacebookController implements Serializable{
1719

1820
private static final long serialVersionUID = 1L;
1921

20-
private FacesContext facesContext = FacesContext.getCurrentInstance();
21-
private HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
22+
private final FacesContext facesContext = FacesContext.getCurrentInstance();
23+
private final ExternalContext externalContext = facesContext.getExternalContext();
24+
private final HttpSession session = (HttpSession) externalContext.getSession(true);
25+
private final Map<String, String> parameterMap = (Map<String, String>) externalContext.getRequestParameterMap();
2226

27+
private final AdministrationController admin = new AdministrationController();
2328
/**
2429
* return la imagen guardada en session por el usuario que se encuentra logueado
2530
* desde Facebook
2631
* @return
2732
*/
2833
public String getProfilePicture(){
29-
session = (HttpSession) facesContext.getExternalContext().getSession(true);
3034
FacebookProfile profile = (FacebookProfile) session.getAttribute("profile");
3135
if(profile==null)
3236
return "";
@@ -40,7 +44,6 @@ public String getProfilePicture(){
4044
* @return
4145
*/
4246
public String getLoggedName(){
43-
session = (HttpSession) facesContext.getExternalContext().getSession(true);
4447
FacebookProfile profile = (FacebookProfile) session.getAttribute("profile");
4548
if(profile==null)
4649
return "";
@@ -54,7 +57,6 @@ public String getLoggedName(){
5457
* @return
5558
*/
5659
public String getFacebookID(){
57-
session = (HttpSession) facesContext.getExternalContext().getSession(true);
5860
FacebookProfile profile = (FacebookProfile) session.getAttribute("profile");
5961
if(profile==null)
6062
return "";
@@ -66,8 +68,17 @@ public String getFacebookID(){
6668
* @return
6769
*/
6870
public boolean isLogged(){
69-
facesContext = FacesContext.getCurrentInstance();
70-
session = (HttpSession) facesContext.getExternalContext().getSession(true);
71+
boolean logged = session.getAttribute("facebook") != null;
72+
if(!logged){
73+
session.setAttribute("lastViewID",admin.getViewId());
74+
75+
if(parameterMap.containsKey("g"))
76+
session.setAttribute("g", parameterMap.get("g"));
77+
78+
if(parameterMap.containsKey("pid"))
79+
session.setAttribute("pid", parameterMap.get("pid"));
80+
81+
}
7182
return session.getAttribute("facebook") != null;
7283
}
7384

src/main/java/org/devdom/tracker/bean/GraphController.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ public String getCommentsGraph(){
139139
" \"title\": \"C#.do\",\n" +
140140
" \"type\": \"smoothedLine\",\n" +
141141
" \"valueField\": \"column-634620033215438\"\n" +
142+
" },\n" +
143+
" {\n" +
144+
" \"balloonText\": \"[[value]] comentarios en [[category]] por [[title]]\",\n" +
145+
" \"bullet\": \"round\",\n" +
146+
" \"id\": \"179901595397349\",\n" +
147+
" \"title\": \"CDDV - Comunidad Dominicana de Desarrolladores de Videojuegos\",\n" +
148+
" \"type\": \"smoothedLine\",\n" +
149+
" \"valueField\": \"column-179901595397349\"\n" +
142150
" }\n" +
143151
" ],\n" +
144152
" \"guides\": [],\n" +
@@ -293,6 +301,14 @@ public String getPostsGraph(){
293301
" \"title\": \"C#.do\",\n" +
294302
" \"type\": \"smoothedLine\",\n" +
295303
" \"valueField\": \"column-634620033215438\"\n" +
304+
" },\n" +
305+
" {\n" +
306+
" \"balloonText\": \"[[value]] post en [[category]] por [[title]]\",\n" +
307+
" \"bullet\": \"round\",\n" +
308+
" \"id\": \"179901595397349\",\n" +
309+
" \"title\": \"CDDV - Comunidad Dominicana de Desarrolladores de Videojuegos\",\n" +
310+
" \"type\": \"smoothedLine\",\n" +
311+
" \"valueField\": \"column-179901595397349\"\n" +
296312
" }\n" +
297313
" ],\n" +
298314
" \"guides\": [],\n" +

src/main/webapp/groupDetails.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<c:choose>
1313
<c:when test="${fb.logged}">
1414
<ui:include src="template/groupMenu.xhtml"/>
15-
<div style="font-size:12px;padding:5px;padding-right:10px;padding-top:0px;">
15+
<div style="width:1070px;font-size:12px;padding:5px;padding-right:10px;padding-top:0px;">
1616
<h3 style="padding:0px;">${group.activity.groupName}</h3>
1717
<div class="group-details">
1818
Detalles estadísticos del grupo <b>${group.activity.groupName}</b>
@@ -56,7 +56,7 @@
5656
border: 0 solid;
5757
}
5858
</style>
59-
<div>
59+
<div style="width:1070px;">
6060
<div style="float:left;padding:3px;width:32%;height:500px;">
6161
<p:dataList style="height:500px;" id="top-interaction-most-liked-post" value="#{topInteraction.topMostLikedPostByGroupId}" var="interaction" type="definition">
6262
<f:facet name="header">Top de publicaciones con más likes</f:facet>

0 commit comments

Comments
 (0)