YoDay Application

8 11 2009

The very first version of my site: http://your-day.appspot.com/home.jsp

It’s like a Twitter but pictorial.

You can log in there with your gmail account.

Current set of features is very basic now:

- search for users (search by “Alex” to find me)
- follow/unfollow a user
- simple statistics
- filling your timeline

I will work on it further on but it is really interesting to know your feedback.

It looks like this:

yoday

Ah, and please use FF browser for now since I have not yet tested it under anything else. Myabe it works under IE/Chrome/etc. as well, just don’t know :)

Any feedback in comments would be great to have.





Stupid Funny HTML Thing: “option” tag’s “selected” attribute usage

4 11 2009

I do know that the HTML is no longer interesting for the major half of the developers but still sometimes you need to use it. Yesterday I’ve encountered one thing that after reading specs made me laugh a lot. I’m talking about “selected” attribute of the “option” tag.
In any programming language (any general language for logical people) normal usage of attributes that are meant by their nature to bee boolean is having 2 possible values to be set: true or false.

“selected” attribute in HTML is a bit different :) To not write a lot here is a receipt:

Specifies that this option will be pre-selected when the user first loads the page.

This is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either selected or selected="selected").

Possible values:

    * [Empty string]
    * selected

So you either specify

<option value="fuck" selected="selected">it</option>

if you want this option to be selected or you should miss the attribute at all. I think this should have been a joke from the dude who created this ))

UPDATE:

I would not post this if this inconvenience did not impact the thing I am doing. It imapcts so I decided to write a little JSP custom tag that fixes the problem in a nice way:

@SuppressWarnings("serial")
public class OptionsTag extends TagSupport {

	public void setDataProvider(List value)
	{
		this.dataProvider = value;
	}

	public void setItemToSelect(DataItem value)
	{
		this.itemToSelect = value;
	}

	public int doStartTag()
	{
		try
		{
			JspWriter out = pageContext.getOut();
			String selected;
			for(DataItem item: dataProvider)
			{
				if (itemToSelect != null)
				{
					selected = itemToSelect.isEqual(item)?"selected='selected'":"";
				}
				else
				{
					selected = "";
				}
				out.println("" + item.getName() + "");
			}
		}
		catch (IOException ioe)
		{
			ioe.printStackTrace();
		}
		return Tag.SKIP_BODY;
	}

	private List dataProvider;
	private DataItem itemToSelect;
}

The usage of the tag in JSPs is straightforward:

<c:if test=”<%=activityCategories!=null%>”>
<select name=”categoryId”>
<components:options dataProvider=”<%=activityCategories%>” itemToSelect=”<%=currentActivityCategory%>”/>
</select>
</c:if>





Java Time

4 09 2009

LOL:

Please note that the all the deprecated methods and constructors of the Date class should never be used. They are from a time when the Sun people were confused about time themselves.

Source: http://www.odi.ch/prog/design/datetime.php