You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2010/01/06 18:52:29 UTC
svn commit: r896580 -
/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Author: arobinson74
Date: Wed Jan 6 17:52:28 2010
New Revision: 896580
URL: http://svn.apache.org/viewvc?rev=896580&view=rev
Log:
Fix NullPointerException in the configuration as there is no user agent at that time
Modified:
myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java?rev=896580&r1=896579&r2=896580&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/agent/AgentFactoryImpl.java Wed Jan 6 17:52:28 2010
@@ -25,9 +25,9 @@
import org.apache.myfaces.trinidad.context.Agent;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.XhtmlConstants;
+
/**
* Trinidad implementation of AgentFactory.
*/
@@ -71,16 +71,22 @@
// consulted to correctly populate the agent
private void _populateAgentImpl(
FacesContext facesContext,
- Map<String, String> headerMap,
+ Map<String, String> headerMap,
AgentImpl agent)
{
-
String userAgent = headerMap.get("User-Agent");
+ if (userAgent == null)
+ {
+ // This will happen during JSF2 initialization
+ _populateUnknownAgentImpl(userAgent, agent);
+ return;
+ }
+
String isEmail = null;
if (facesContext != null)
isEmail = facesContext.getExternalContext().getRequestParameterMap().
get(_EMAIL_PARAM);
-
+
if ("true".equals(isEmail))
{
_populateEmailAgentImpl(agent);
@@ -387,7 +393,7 @@
agentObj.setAgent(Agent.AGENT_IE);
agentObj.setAgentVersion(version);
agentObj.setPlatform(Agent.PLATFORM_PPC);
-
+
boolean narrowScreenDevice = false;
if(uaPixels != null && uaPixels.length() > 0)
@@ -418,7 +424,7 @@
{
agentObj.__addRequestCapability(TrinidadAgent.CAP_WIDTH,width);
agentObj.__addRequestCapability(TrinidadAgent.CAP_HEIGHT,height);
-
+
if (width.intValue() < XhtmlConstants.NARROW_SCREEN_PDA_MAX_WIDTH)
{
narrowScreenDevice = true;
@@ -433,15 +439,15 @@
{
narrowScreenDevice = true;
}
-
+
if (narrowScreenDevice)
{
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.TRUE);
}
else
{
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.FALSE);
}
}
@@ -488,9 +494,9 @@
agentObj.setAgentVersion(version);
agentObj.setPlatform(Agent.PLATFORM_BLACKBERRY);
agentObj.setMakeModel(makeModel);
- // Most of BlackBerry devices' widths are more than 240px, so
+ // Most of BlackBerry devices' widths are more than 240px, so
// don't consider BlackBerry as a narrow-screen PDA.
- agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
+ agentObj.__addRequestCapability(TrinidadAgent.CAP_NARROW_SCREEN,
Boolean.FALSE);
}
@@ -700,7 +706,7 @@
// so just return. It will be handle by _populateGenricPDAImpl().
else if (agent.indexOf("MOT-") != -1 || agent.indexOf("Nokia") != -1)
{
- return;
+ return;
}
else
{
@@ -888,14 +894,14 @@
}
}
}
-
+
/**
* Returns an AgentEntry for the email agents like Outlook 2007 and
* Thunderbird
*/
private void _populateEmailAgentImpl(AgentImpl agentObj)
{
-
+
agentObj.setType(Agent.TYPE_DESKTOP);
agentObj.setAgent(Agent.AGENT_EMAIL);
@@ -904,7 +910,7 @@
agentObj.setPlatformVersion(Agent.PLATFORM_VERSION_UNKNOWN);
agentObj.setMakeModel(Agent.MAKE_MODEL_UNKNOWN);
- }
+ }
/**