Fóruns

Início » Liferay Portal » English » 2. Using Liferay » General

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Monalisa Sahu
Weather Portlet
28 de Fevereiro de 2012 04:39
Resposta

Monalisa Sahu

Ranking: New Member

Mensagens: 2

Data de entrada: 28 de Fevereiro de 2012

Mensagens recentes

Can anybody send me weather portlet
David H Nebinger
RE: Weather Portlet
28 de Fevereiro de 2012 05:08
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 9482

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Whatever you guys are working on, you should share notes.

Review all of the other recent posts on the weather portlet: where to get it, how to deploy it, how to configure it, and why invalid params result in blank screen.
Monalisa Sahu
RE: Weather Portlet
28 de Fevereiro de 2012 05:40
Resposta

Monalisa Sahu

Ranking: New Member

Mensagens: 2

Data de entrada: 28 de Fevereiro de 2012

Mensagens recentes

where should i put the war file of weather portlet in order to deploy it
David H Nebinger
RE: Weather Portlet
28 de Fevereiro de 2012 05:44
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 9482

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Again, this has all been covered in recent weeks as your friends have been doing the same things.

Search the forum to find the info.
Dave Weitzel
RE: Weather Portlet
6 de Dezembro de 2012 13:02
Resposta

Dave Weitzel

Ranking: Regular Member

Mensagens: 195

Data de entrada: 18 de Novembro de 2009

Mensagens recentes

Google has now stopped providing the weather api used in the portlet so it is not usable until updated to a new API
Hitoshi Ozawa
RE: Weather Portlet
6 de Dezembro de 2012 14:17
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7949

Data de entrada: 23 de Março de 2010

Mensagens recentes

It's already been fixed.

http://issues.liferay.com/browse/LPS-29542
Jitendra Rajput
RE: Weather Portlet
6 de Dezembro de 2012 21:45
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 858

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

If you want to check code then look into WeatherWebCacheItem.java .
Old code with google API was like this

 1
 2public Object convert(String key) throws WebCacheException {
 3        Weather weather = null;
 4
 5        try {
 6            String text = HtmlUtil.stripComments(HttpUtil.URLtoString(
 7                "https://www.google.com/ig/api?weather=" +
 8                    HttpUtil.encodeURL(_zip)));
 9
10            int x = text.indexOf("temp_f data");
11
12            x = text.indexOf("\"", x) + 1;
13
14            int y = text.indexOf("\"", x);
15
16            float temperature = GetterUtil.getFloat(text.substring(x, y));
17
18            x = text.indexOf("/images", x);
19            y = text.indexOf("\"", x);
20
21            String iconURL = "https://www.google.com" + text.substring(x, y);
22
23            weather = new Weather(_zip, iconURL, temperature);
24        }
25        catch (Exception e) {
26            throw new WebCacheException(_zip);
27        }
28
29        return weather;
30    }


And new code with API change

 1
 2 public Object convert(String key) throws WebCacheException {
 3        Weather weather = null;
 4
 5        try {
 6            StringBundler sb = new StringBundler(5);
 7
 8            sb.append("http://free.worldweatheronline.com/feed/weather.ashx?key=");
 9            sb.append(WeatherPropsUtil.get("world.weather.online.api.key"));
10            sb.append("&q=");
11            sb.append(HttpUtil.encodeURL(zipName));
12            sb.append("&format=xml");
13            
14            String xml = HtmlUtil.stripComments(HttpUtil.URLtoString(sb.toString()));
15
16            Document document = SAXReaderUtil.read(xml);
17
18            Element rootElement = document.getRootElement();
19
20            Element currentConditionElement = rootElement.element(
21                "current_condition");
22
23            Element temperatureElement = currentConditionElement.element("temp_F");
24
25            float temperature = GetterUtil.getFloat(temperatureElement.getData());
26
27            Element iconElement = currentConditionElement.element("weatherIconUrl");
28
29            String iconURL = iconElement.getText();
30
31            weather = new Weather(zipName, iconURL, temperature);
32        }
33        catch (Exception e) {
34            throw new WebCacheException(zipName);
35        }
36
37        return weather;
38    }