You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/09/21 04:35:26 UTC

Query Parameter Suggestions

Hello, I'm currently taking some time to upgrade my personal application,
CarDaddy.com from version 5.1 to 5.3.

I'm looking for suggestions in regards to Tapestries query parameters.
Currently we are passing a list into activation context, but I'm wondering
if it would be better to use a query string? The query string doesn't seem
nearly as clean as activation context, but does seem to describe the URL
better. In my situation, is there any positives or negatives to using either
or? SEO, web services etc? SEO would be the highest on my priority list.
Another thing I'd like to do is add a keyword search, so that is also
another deciding factor. 

I did find an example of both thanks to Geoff's JumpStart examples. 
http://jumpstart.doublenegative.com.au/jumpstart/examples/state/passingdatabetweenpages

Any insight would be greatly appreciated.  Thanks in advance. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
> I've always been told to use them
I wasn't saying don't use them... I was saying that I'd be surprised if a
search engine would use them any differently to whitespace.

Does this mean that you have page class names with underscores in them? Or
do you have a mechanism to tell tapestry to convert CamelCase to camel_case?

> As always Lance, Thank you for your valuable input.
No problem



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716444.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
Thanks Thiago, I will look into that API. The site is actually starting to
grow a bit more rapidly now, so I think it's about time I start taking it a
bit more seriously and fix all the bugs. :) Now I just need to find more
time to mess with it :-/



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716443.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
Interesting, I've always been told to use them in order to help search
engines to determine the URL content. As always Lance, Thank you for your
valuable input. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716442.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
> I also noticed tapestry can't handle dashes like used-car-for-sale
I haven't noticed this. What does tapestry do?

> Do you know if search engines treat them equally?
I'd assume that search engines ignore them. Since google's ranking algorithm
is a well-kept secret, it's impossible to know.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716440.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 21 Sep 2012 11:17:23 -0300, George Christman  
<gc...@cardaddy.com> wrote:

> I also noticed tapestry can't handle dashes like used-car-for-sale,  
> instead I need to use underscores, used_car_for_sale.

Tapestry does handle dashes in query parameters and activation contexts,  
just not in page names, as they should be valid Java identifiers.

> Do you know if search engines
> treat them equally? If not, would you recommend a URL rewriter?

LinkTransformer API is there for that.

-- 
Thiago H. de Paula Figueiredo

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
Thanks Lance for your suggestions. I'm very aware of non URL improvements
which are improvements I'll be working into the redesign, but currently just
focused on my URL structure. 

I also noticed tapestry can't handle dashes like used-car-for-sale, instead
I need to use underscores, used_car_for_sale. Do you know if search engines
treat them equally? If not, would you recommend a URL rewriter?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716438.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
> we're currently doing the following:
www.cardaddy.com/carsearch/1/5/2/10/3/4 
For maximum SEO, it's best to include keywords in the URL. That being said
there are many non-URL-related improvements you can make to a website to
improve SEO.

> I'm assuming for keyword searches I would just use "keyword" as a key in
> the activation context? 
Sounds about right... I'd say that the keys more or less map to your DB
column names.

> I'm wondering if you would just pass the parameters into activation
> context as a List and just ignore the descriptive string? 
That's certainly possible, or you could create unique string column on each
table which could be used to lookup your rows and ditch the number all
together.

> Example of what we'ere currently doing: 
> void onActivate(List<String> parameters)

You can also use the following if you'd like to use tapestry's type
coercion:
void onActivate(EventContext context)






--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716435.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
> I use underscores in the page names rather than camel case
It's not a huge problem... but it's not a standard way of naming a java
class either. If it was bothering you, you could decorate the
ComponentEventLinkEncoder to convert CamelCase to camel-case.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716447.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by trsvax <tr...@gmail.com>.
The default for @Persist is to use the session so things like grid will
persist the page number, sort order etc. in the session. If you make
MultiStatePersistenceStrategy the default these will now be persisted as
query parameters.  You can also just use @Persist in a page. For example if
you have a page that lists users perhaps by last name


public class UserReport<T> {
	
	@Property
	List<T> users;
	
	@Persist
        @Property
	private String name;
	
	@Property
	BeanModel<T> model;

	@Inject
	private Session session;
	
	@Inject
	private SQLModelSource<T> source;
	
	@Inject
	private ComponentResources resources;
	
	private final String sql = "select * from person";
	
	@SuppressWarnings("unchecked")
	@SetupRender
	void setupRender() {
		GridTransformer<T> transformer =
source.gridTransformer(resources.getMessages());

		if ( name != null ) {
			users = session.createSQLQuery(sql + " where lastName like :name"
).setString("name", name + "%").setResultTransformer(transformer).list();
		} else {
			users =
session.createSQLQuery(sql).setResultTransformer(transformer).list();
		}
		
		model = transformer.model();
	}	
	
}

with a tml file like

<html t:type="layout" title="User Report"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">
      
      <t:form>
      	<t:textfield value="name"/>
      	<t:submit value="Search"/>
      </t:form>
      <t:grid t:id="users" model="model"
include="id,lastname,firstname,email,birthdate" rowsPerPage='6'/>    
</html>

The grid will now persist all it's data in query parameters instead of the
session and the page value for name will also become a query parameter. For
example a url like

/user/report?users;currentPage=1&users;sortAscending=true&users;sortColumnId=id&name=B

will show the first page of users sorted by the id column whose lastName
begins with B and unlike persisting in the session the url is bookmarkable,
the back button works etc.

You can also just enable it by page with
@Meta("tapestry.persistence-strategy=multi")

In other words @Persist works more or less like @PageActivationContext where
the activation context is stored in the path part of the url and @Persist
fields are stored as query parameters.




--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716448.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
Lance, I use underscores in the page names rather than camel case. I've never
had any issues doing it, just not sure if it's good practice. 

Hi trsvax, I'm not completely sure I understand the idea behind your
suggestion? Could you possible provide a use case where this would come in
handy? Thanks



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716446.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by trsvax <tr...@gmail.com>.
You might be interested in this

https://github.com/trsvax/Jacquard/blob/master/src/main/java/com/trsvax/jacquard/services/MultiStatePersistenceStrategyImpl.java

It enables @Persist to use url query parameters. It's possible to make it
the default persist strategy in which case things such as the existing grid
component will have urls such as 

user/report?users;currentPage=1&users;sortAscending=true&users;sortColumnId=id

If you make it the default it's unwise to persist large objects but it will
use value encoders. For example if you are using Hibernate

@Persist
private User user

will put the primary key of the user into the url;

If used correctly this will allow bookmarking grid pages for searches that
use a grid to display.

To make it the default

 public static void contributeFactoryDefaults(MappedConfiguration<String,
Object> configuration) {
        configuration.override(SymbolConstants.PERSISTENCE_STRATEGY,
"multi");
 }

FYI: It would be really nice if the default persist strategy was a chain so
you could decline to persist something.




--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716445.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
I'm also taking into consideration bookmarked search results, emailing urls,
or saved search results. That would be the only reason I would want to store
those parameters in the url. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716439.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
> would you just pass any sort/pager parameters in as a key/value pair too
Possibly not, think about what people will be googling for and make sure
that's in the URL.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716436.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by George Christman <gc...@cardaddy.com>.
Hi Lance, your approach using key/value is the same approach were currently
using, however yours is much better since your using descriptive parameters
rather than just primary keys. 

Although horrible for SEO, we're currently doing the following,
eg www.cardaddy.com/carsearch/1/5/2/10/3/4

I definitely like your approach much better since it seems to be better for
SEO. 

I'm assuming for keyword searches I would just use "keyword" as a key in the
activation context?

Lastly, I'm still up in the air as to whether or not I'm going to use a
pager or use auto expanding results similar to Google's image search or the
Facebook wall, but none the less, I will still have sort parameters. With
that being said, would you just pass any sort/pager parameters in as a
key/value pair too? Example "price-sort/desc".

Now this is separate from the above question, but similar at the same time.
I notice on some websites, you will see on the product description page, the
url parameters contain a pk followed by a descriptive string. The page will
however load with just the pk and not the descriptive string. I'm wondering
if you would just pass the parameters into activation context as a List and
just ignore the descriptive string?

Example www.cardaddy.com/used_car_for_sale/9535542/2012-porsche-911-coupe

If there is better ways to handle activation context than passing a list in,
please advise. 

Example of what we'ere currently doing. 

void onActivate(List<String> parameters) {

}

Thanks everyone. 






--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716432.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
Not sure if it's a good idea or not but you could provide a similar function
to request parameters using key/value pairs in activation context.

eg www.cardaddy.com/carsearch/make/porsche/model/911/colour/red



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716423.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Query Parameter Suggestions

Posted by Lance Java <la...@googlemail.com>.
As you suspected, query parameters don't score as high for SEO as activation
context parameters. Sometimes, query parameters are a necessary evil when
you have optional fields. Tapestry will treat "$N" as null if you want to
pass a null activation context parameter.

Perhaps if you provide an example URL we could help you more.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Query-Parameter-Suggestions-tp5716416p5716422.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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