Javascript if else?

B

Brie_Manakul

Is there a way in javascript to do an if else that shows a script in an
iframe? Let me know if that doesn't make sense. We have a portal and
in a portlet I need to grab these javascript links to display in the
portlet if a user selects a certain city. Let me know if this can be
done. Below is my code. Any help would be greatly appreaciated.
Thanks!


<%@ page language="java" import="java.util.*, java.text.* " %>
<%@ page import="com.plumtree.remote.portlet.*" %>
<%@ page import="com.plumtree.remote.prc.*" %>
<%
String path = request.getContextPath();
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% response.setHeader("Cache-Control", "max-age=3400"); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>Weather</title>

<!-- <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> -->
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel='stylesheet'
href='pt://images/plumtree/portal/custom/fh_styles/style.css'>
-->
<body>
<table>
<tr></td>
<script>

if (city="albany")
{
open("http://voap.weather.com/weather/oap...l&unit=0&key=ba8a960da18891295bbc4cfea6a0dbe2");

}
else if(city="amsterdam")
{
window.open("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if(city="atlanta")
{

window.open("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='austin')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='beijing')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='berlin')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='boston')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='brussels')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='buffalo')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='calgary')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e'")
}
else if (city='charlotte')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e'")
}
else if (city='chicago')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e'")
}
else if (city='cleveland')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='dallas')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='detroit')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='dublin')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='edinburgh')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e'")
}
else if (city='edmonton')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='frankfurt')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='hongkong')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='houston')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='johannesburg')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='kansascity')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='kualalumpur')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='london')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='losangeles')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='madrid')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='manila')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='melbourne')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='mexico')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='miami')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='milan')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='minneapolis')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='montreal')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=91722c3a3c6b8b302602ce2bf13950ae")
}
else if (city='munich')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='neworleans')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='newyork')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='ottawa')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='paris')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='portland')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='prague')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='quebec')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='raleighdurham')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sacramento')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sanantonio')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sandiego')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sanfrancisco')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sanjuan')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='seattle')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='seoul')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='shanghai')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='singapore')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='StLouis')
{

String("http://voap.weather.com/weather/oap...l&unit=0&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='sydney')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='tokyo')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='toronto')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if (city='vancouver')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}
else if(city='warsaw')
{

String("http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e")
}


</script>

</td></tr></table>
</body>
 
W

web.dev

Is there a way in javascript to do an if else that shows a script in an
iframe? Let me know if that doesn't make sense. We have a portal and
in a portlet I need to grab these javascript links to display in the
portlet if a user selects a certain city. Let me know if this can be
done. Below is my code. Any help would be greatly appreaciated.
Thanks!

Before proceeding to finding you a solution, let's fix your script
first.

You're missing the type attribute:


In situations like these where you have many if..else statements, using
a switch statement would be more efficient. Also, there is no need to
create a new String, just do something like the following:

var alink = "";

switch(city)
{
case "albany":
alink = "http://URI";
break;
case "warsaw":
alink = "http://URI";
break;
}

window.open(alink, ...); //place other attributes that you need.
 
B

Brie_Manakul

I'm not sure that I fully understand.

I changed these points:

if (city="albany")
{
open("http://voap.weather.com/weather/oap/USTX0016?template=GENXH&par=null&...");

[...snip...]

else if(city='warsaw')
{

To set up the switch i'm a little confused Sorry!! Do you mean like
this:

<%@ page language="java" import="java.util.*, java.text.* " %>
<%@ page import="com.plumtree.remote.portlet.*" %>
<%@ page import="com.plumtree.remote.prc.*" %>
<%
String path = request.getContextPath();
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% response.setHeader("Cache-Control", "max-age=3400"); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>Weather</title>

<!-- <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> -->
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel='stylesheet'
href='pt://images/plumtree/portal/custom/fh_styles/style.css'>
-->
<body>


<table>
<tr><td>
<script type = "text/javascript">
var alink = "";

switch(city)
{
case "albany":
alink =
"http://voap.weather.com/weather/oap...l&unit=0&key=ba8a960da18891295bbc4cfea6a0dbe2";
break;
case "warsaw":
alink =
"http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e";
break;

}

</script>

</td></tr></table>
</body>

Then city is undefined?
 
W

web.dev

<script type = "text/javascript">
var alink = "";

switch(city)
{
case "albany":
alink =
"http://voap.weather.com/weather/oap...l&unit=0&key=ba8a960da18891295bbc4cfea6a0dbe2";
break;
case "warsaw":
alink =
"http://voap.weather.com/weather/oap...l&unit=1&key=67d2b0264796112ce6d75944acad734e";
break;

}

Don't forget to add the cases for your other cities.
Then city is undefined?

Correct. In your original script, city was undefined. Where are you
getting this value from?
 
B

Brie_Manakul

This is actually a portlet within a portal. So I had to set up two
other pages to go with it. I'll paste the code in so you can see it.

Userprefs:


<%@ page language="java" import="java.util.*" %>
<%@ page import="com.plumtree.remote.portlet.*" %>
<%@ page import="com.plumtree.remote.prc.*" %>
<%
String path = request.getContextPath();
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>Edit Preferences</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<link rel='stylesheet'
href='pt://images/plumtree/portal/custom/fh_styles/style.css'>

<script LANGUAGE="JavaScript">
<!--
window.moveTo(100,100);
if (window.screen) self.resizeTo(Width=700,Height=400);

//-->
</script>

</head>

<body>
<%
String cityName = null;
try
{
//get portlet context obj
IPortletContext portletContext =
PortletContextFactory.createPortletContext(request, response);
IRemoteSession remoteSession =
portletContext.getRemotePortalSession();

//Get portlet context object
IPortletRequest portletRequest = portletContext.getRequest();
cityName = portletRequest.getSettingValue(SettingType.User,
"cityName");
if (cityName != null)
{
System.out.println("FHWeather: userPrefs: previous selected
cityName = " + cityName);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
%>
<form name="userprefs" method="post" action="setUserPrefs.jsp"
id="userPrefs">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td colspan=4
background="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/horiz_greyrule.gif">
<img
src="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/tr.gif"
width="1" height="1"></td>
</tr>
<tr><td colspan=4><p class="pagetitle">Edit Preferences</p>
<p class="pagetext">Use this page to Edit preferences for this
portlet. Click Submit to return to the previous page.</p></td></tr>
<tr><td width="29%">&nbsp;</td></tr>
<tr>
<td colspan=4
background="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/horiz_greyrule.gif">
<img
src="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/tr.gif"
width="1" height="1"></td>
</tr>


<tr>
<td valign="top" class="bodytext">Select the cities weather:</td>
<td valign="top" align="left" width="20%"> <table>
<% if (cityName != null && cityName.equalsIgnoreCase("albany"))
{
%>
<tr><td width="126" align="left" class="bodytext"><input
type="radio" name="cityName" value="Albany" checked>Albany</td></tr>
<% }
else
{ %>
<tr><td align="left" class="bodytext"><input type="radio"
name="cityName" value="Albany" >Albany</td></tr>
<% } %>


</table></td>
<td valign="top" align="left" width="20%"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("amsterdam"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Amsterdam" checked>
Amsterdam</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Amsterdam" >
Amsterdam</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left" width="20%"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("atlanta"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Atlanta" checked>
Atlanta</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Atlanta" >
Atlanta</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("austin"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Austin" checked>
Austin</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Austin" >
Austin</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("beijing"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Beijing" checked>
Beijing</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Beijing" >
Beijing</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("berlin"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Berlin" checked>
Berlin</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Berlin" >
Berlin</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("boston"))
{
%>
<tr>
<td width="143" align="left" class="bodytext"><input
type="radio" name="cityName" value="Boston" checked>
Boston</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Boston" >
Boston</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("brussels"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Brussels" checked>
Brussels</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Daily" >
Brussels</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("buffalo"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Buffalo" checked>
Buffalo</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Buffalo" >
Buffalo</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("calgary"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Calgary" checked>
Calgary</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Calgary" >
Calgary</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("charlotte"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Charlotte" checked>
Charlotte</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Charlotte" >
Charlotte</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("chicago"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Chicago" checked>
Chicago</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Chicago" >
Chicago</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("cleveland"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Cleveland" checked>
Albany</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Cleveland" >
Cleveland</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("dallas"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Dallas" checked>
Dallas</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Dallas" >
Dallas</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("detroit"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Detroit" checked>
Detroit</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Detroit" >
Detroit</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("dublin"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Dublin" checked>
Dublin</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Dublin" >
Dublin</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("edinburgh"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Edinburgh" checked>
Edinburgh</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Edinburgh" >
Edinburgh</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("edmonton"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Edmonton" checked>
Edmonton</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Edmonton" >
Edmonton</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("frankfurt"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Frankfurt" checked>
Frankfurt</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Frankfurt" >
Frankfurt</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("hongkong"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="HongKong" checked>
Hong Kong</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="HongKong" >
Hong Kong</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("houston"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Houston" checked>
Houston</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Houston" >
Houston</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("johannesburg"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Johannesburg" checked>
Johannesburg</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Johannesburg" >
Johannesburg</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("kansascityName"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="KansascityName" checked>
Kansas cityName</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="KansascityName" >
Kansas cityName</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("kualalumpur"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="KualaLumpur" checked>
Kuala Lumpur</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Kuala Lumpur" >
Kuala Lumpur</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("london"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="London" checked>
London</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="London" >
London</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("losangeles"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="LosAngeles" checked>
Los Angeles</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Los Angeles" >
Los Angeles</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("madrid"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Madrid" checked>
Madrid</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Madrid" >
Madrid</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("manila"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Manila" checked>
Manila</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Manila" >
Manila</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("melbourne"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Melbourne" checked>
Melbourne</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Melbourne" >
Melbourne</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("mexico"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Mexico" checked>
Mexico</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Mexico" >
Mexico</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("miami"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Miami" checked>
Miami</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Miami" >
Miami</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("milan"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Milan" checked>
Milan</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Milan" >
Milan</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("minneapolis"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Minneapolis" checked>
Minneapolis/St. Paul</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Minneapolis" >
Minneapolis/St. Paul</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("montreal"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Montreal" checked>
Montreal</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Montreal" >
Montreal</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("munich"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Munich" checked>
Munich</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Munich" >
Munich</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("neworleans"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="NewOrleans" checked>
New Orleans</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="New Orleans" >
New Orleans</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("newyork"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="NewYork" checked>
New York</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="New York" >
NewYork</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("ottawa"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Ottawa" checked>
Ottawa</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Ottawa" >
Ottawa</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("paris"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Paris" checked>
Paris</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Paris" >
Paris</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("portland"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Portland" checked>
Portland</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Portland" >
Portland</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("prague"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Prague" checked>
Prague</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Prague" >
Prague</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("quebec"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Quebec" checked>
Albany</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Quebec" >
Quebec</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("raleighdurham"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="RaleighDurham" checked>
Raleigh-Durham</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="RaleighDurham" >
Raleigh Durham</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sacramento"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Sacramento" checked>
Sacramento</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Sacramento" >
Sacramento</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sanantonio"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="SanAntonio" checked>
San Antonio</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="San Antonio" >
San Antonio</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sandiego"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="SanDiego" checked>
San Diego</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="SanDiego" >
San Diego</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sanfrancisco"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="SanFrancisco" checked>
San Francisco</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="SanFrancisco" >
San Francisco</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sanjuan"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="SanJuan" checked>
San Juan</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="SanJuan" >
San Juan</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("seattle"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Seattle" checked>
Seattle</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Seattle" >
Seattle</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("seoul"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Seoul" checked>
Seoul</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Seoul" >
Seoul</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("shanghai"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Shanghai" checked>
Shanghai</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Shanghai" >
Shanghai</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("singapore"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Singapore" checked>
Singapore</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Singapore" >
Singapore</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("StLouis"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="StLouis" checked>
St. Louis</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="StLouis" >
St. Louis</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("sydney"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Sydney" checked>
Sydney</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Sydney" >
Sydney</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("tokyo"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Tokyo" checked>
Tokyo</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Tokyo" >
Tokyo</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("toronto"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Toronto" checked>
Toronto</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Toronto" >
Toronto</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("vancouver"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Vancouver" checked>
Vancouver</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Vancouver" >
Vancouver</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td valign="top" class="bodytext">&nbsp;</td>
<td valign="top" align="left">
<table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("warsaw"))
{
%>
<tr>
<td width="146" align="left" class="bodytext"><input
type="radio" name="cityName" value="Warsaw" checked>
Warsaw</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Warsaw" >
Warsaw</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("washington"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Washington" checked>
Washington D.C.</td>
</tr>
<% }
else
{ %>
<tr>
<td height="21" align="left" class="bodytext"><input
type="radio" name="cityName" value="Washington" >
Washington D.C.</td>
</tr>
<% } %>
</table></td>
<td valign="top" align="left"><table>
<% if (cityName != null &&
cityName.equalsIgnoreCase("albany"))
{
%>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Albany" checked>
Albany</td>
</tr>
<% }
else
{ %>
<tr>
<td align="left" class="bodytext"><input type="radio"
name="cityName" value="Daily" >
Albany</td>
</tr>
<% } %>
</table></td>
</tr>
<tr>
<td class="bodytext"><input type="submit" name="SubmitButton"
id="SubmitButton" value="Submit"></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td colspan=4
background="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/horiz_greyrule.gif">
<img
src="pt://images/plumtree/portal/custom/fh_images/rec_port_graphics/tr.gif"
width="1" height="1"></td>
</tr>
</table>
</form>
<jsp:include page="FHFooter.jsp"/>

</body>
</html>


Set UserPrefs:


<%@ page language="java" import="com.plumtree.remote.portlet.*"
contentType="text/html;charset=UTF-8" %>
<%
String path = request.getContextPath();
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'setAdminPrefs.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>

<body>
<%
//Get portlet context object
IPortletContext portletContext =
PortletContextFactory.createPortletContext(request,response);
IPortletResponse portletResponse = portletContext.getResponse();

//Get user name from incoming form, and set it into the
portletResponse
String cityName = request.getParameter("cityName");
if (cityName == null)
{
System.out.println("FHWeather: setUserPrefs: selected cityName is
null, set default StLouis");
cityName = "StLouis";
}

System.out.println("FHWeather: setUserPrefs: cityName = " +
cityName);

IPortletRequest portletRequest = portletContext.getRequest();
portletResponse.setSettingValue(SettingType.User, "cityName",
cityName);

System.out.println("FHWeather: setUserPrefs: cityName = " +
portletRequest.getSettingValue(SettingType.User, "cityName"));

portletResponse.returnToPortal();
%>
</body>
</html>


Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top