473,382 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Javascript question on displaying contents of a webpage in a portlet

I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
if (cityName.toLowerCase() ==
cityName[i].cityName.toLowerCase())
{
open (weatherURL);
break;
}

var cityName = [
{ cityName: 'austin',
weatherURL: "austin.html" },
{ cityName: "albany",
weatherURL: "albany.html" },
{ cityName: "amsterdam",
weatherURL: "amsterdam.html" },
{ cityName: "beijing",
weatherURL: "beijing.html" },
{ cityName: "berlin",
weatherURL: "berlin.html" }

];
</script>
Thanks!
Brie

Feb 9 '06 #1
4 1967

Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length; i++)
if (cityName.toLowerCase() ==
cityName[i].cityName.toLowerCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.forms["formName"].elements["cityName"].value.toLowerCase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.

Feb 9 '06 #2

Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)
i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length; i++)
if (cityName.toLowerCase() ==
cityName[i].cityName.toLowerCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.forms["formName"].elements["cityName"].value.toLowerCase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.

Feb 9 '06 #3

web.dev wrote:
Brie wrote:
I have a user preferences page where users select what city they're
with. Once they choose that a certain page shows in a portlet on their
intranet page. I can't get this to work. Here's the code I have for
it to show those corresponding pages. Does anyone know what i'm doing
wrong? Any help would be greatly appreciated.

<script type="text/javascript">

for (var i = 0; i < cityName; i++)


i < cityName ?

1. You're using cityName before you even have it defined.
2. You're comparing a number to an object.

You probably really meant this:

for(var i = 0; i < cityName.length; i++)
if (cityName.toLowerCase() ==
cityName[i].cityName.toLowerCase())


Now you've confused me. Do you have in your form an element with the
name "cityName" ? The expression on the left hand side makes me assume
so. In which case, you should then access it properly:

if(document.forms["formName"].elements["cityName"].value.toLowerCase()
== ...)

And finally, where is your script defined? The way it is at the
moment, it'll execute right away. Meaning, since it's not contained in
a function and you're waiting for a response from the user, it's
useless.


Here's where the script is defined. THis is another page:

<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 albany");
cityName = "albany";
}

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!

Feb 9 '06 #4

Brie wrote:
Here's where the script is defined. THis is another page:
<% [snip] %>


Where is the script defined? Posting server-side script is not very
useful. Instead, you should post what the client receives.

Feb 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: allerhed | last post by:
Hi! Is there any one who has toyed around with the portlet container from jakarta-pluto(JSR-168)? I'm trying to render a known portlet ( I have the context path of the portlet as identifier) in a...
2
by: Eli | last post by:
Hi gurus, My question is about exchanging data on a basic HTML page between a JavaScript piece of code and a Java client-side <APPLET> residing on the same webpage. To demonstrate the idea of...
1
by: Brett | last post by:
I am writing a program that will allow a user to enter a webpage address into a form. Then it will download and display the webpage below the current one. example...
5
by: Brie_Manakul | last post by:
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...
4
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*,...
0
by: Mario | last post by:
Hi I have to make few portals for all departments in my company. One portal for one department. Each portal has to present information about department employees. I have written WSRP portlet,...
2
by: mahesh.mohan1 | last post by:
Hi All, I am trying to deploy one of the portal applications on websphere 6.1. During the course of deployment, I get the following error: EJPPC0005E: portlet.xml validation caught a...
5
by: gyip | last post by:
My environment: IE7 browser hitting an ASP.NET webpage that uses Javascript to render the contents. This is not an ASP.NET problem but a Javascript problem that I am encountering. Problem:...
2
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.