You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Leangen <dl...@canada.com> on 2005/04/09 19:55:58 UTC

Browser detection component?

Anybody know where I can find a browser detection component?


Thanks!
Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Browser detection component?

Posted by Matt Raible <li...@raibledesigns.com>.
David Leangen wrote:

>Thanks, Kent.
>
>Since I need this, I will gladly code it in Java and contribute it back to
>the Tapestry project.
>
>However, before I begin... does anybody already have a Java class that does
>this, so I don't have to reinvent the wheel?
>  
>
Here's one I used on a project a couple of years ago:

public final class DetectBrowser implements Serializable {

    private HttpServletRequest request = null;
    private String useragent = null;
    private boolean netEnabled = false;
    private boolean ie = false;
    private boolean ns = false;
    private boolean mac = false;
    private boolean win = false;

    public void setRequest(HttpServletRequest req)
    {
        request = req;
        useragent = request.getHeader("User-Agent");
        String user = useragent.toLowerCase();

        if (user.indexOf("msie") != -1) {
            ie = true;
        } else if (user.indexOf("gecko") != -1) {
            ns = true;
        }

        if (user.indexOf("mac") != -1) {
            mac = true;
        }

    }

    public String getUseragent()
    {
        return useragent;
    }

    public boolean isNetEnabled()
    {
        return netEnabled;
    }

    public boolean isIE()
    {
        return ie;
    }

    public boolean isNS()
    {
        return ns;
    }

    public boolean isMac()
    {
        return mac;
    }
}

>
>Thanks!
>Dave
>
>
>
>
>  
>
>>-----Original Message-----
>>From: news [mailto:news@sea.gmane.org]On Behalf Of Kent Tong
>>Sent: 12 April 2005 11:22
>>To: tapestry-user@jakarta.apache.org
>>Subject: Re: Browser detection component?
>>
>>
>>David Leangen <dleangen <at> canada.com> writes:
>>
>>    
>>
>>>Anybody know where I can find a browser detection component?
>>>      
>>>
>>I'm unaware of any such component, but you can get a
>>javascript to do that at
>>http://www.dithered.com/javascript/browser_detect/browser_detect.txt
>>
>>If you'd like, you can convert it to a component. However,
>>as it is not generating any html code, it doesn't look
>>like a good candidate for a component to me. I'd code it
>>in a Java class (eg, BrowserDetector.java).
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Browser detection component?

Posted by David Leangen <dl...@canada.com>.
Thanks, Kent.

Since I need this, I will gladly code it in Java and contribute it back to
the Tapestry project.

However, before I begin... does anybody already have a Java class that does
this, so I don't have to reinvent the wheel?


Thanks!
Dave




> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Kent Tong
> Sent: 12 April 2005 11:22
> To: tapestry-user@jakarta.apache.org
> Subject: Re: Browser detection component?
>
>
> David Leangen <dleangen <at> canada.com> writes:
>
> >
> > Anybody know where I can find a browser detection component?
>
> I'm unaware of any such component, but you can get a
> javascript to do that at
> http://www.dithered.com/javascript/browser_detect/browser_detect.txt
>
> If you'd like, you can convert it to a component. However,
> as it is not generating any html code, it doesn't look
> like a good candidate for a component to me. I'd code it
> in a Java class (eg, BrowserDetector.java).
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Browser detection component?

Posted by Kent Tong <ke...@cpttm.org.mo>.
David Leangen <dleangen <at> canada.com> writes:

> 
> Anybody know where I can find a browser detection component?

I'm unaware of any such component, but you can get a
javascript to do that at
http://www.dithered.com/javascript/browser_detect/browser_detect.txt

If you'd like, you can convert it to a component. However,
as it is not generating any html code, it doesn't look
like a good candidate for a component to me. I'd code it
in a Java class (eg, BrowserDetector.java).



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org