Hi folks!
This is no more an issue for me.
The problematic behaviour from the filter preventing the possibility to
have several query string parameters with the same name has been fixed.
In consequences, I removed my ugly patch!
/Martin
Martin Carel wrote:
Hi!
I have had problems lately with the fact that the DirectLink component
uses service parameters with all the same parameter names
(ServiceConstants.PARAMETER, that is, "sp"). This is in fact a problem
for me, as I have a servlet filter which wraps any request and puts
all the query string values into a Map (so if query string parameters
have the same name, only one gets in the Map). Right now, I cannot
afford to change this (probably problematic) behaviour.
The contrib:Table component uses for instance 2 service parameters
(sp=value1&sp=value2) for its sorting and paging features. Somehow, I
needed to have different query string parameter names for each service
parameters. So I had the courage to do a *really ugly* patch in
LinkFactoryImpl, which so far meets my needs (sorting and paging now
works fine with my contrib:Table). Here is what it looks like:
protected void squeezeServiceParameters(Map parameters)
{
Object[] serviceParameters = (Object[])
parameters.get(ServiceConstants.PARAMETER);
if (serviceParameters == null)
return;
String[] squeezed = squeeze(serviceParameters);
//** BEGIN patch **
if(squeezed.length == 2){
parameters.put(ServiceConstants.PARAMETER + "1", squeezed[0]);
parameters.put(ServiceConstants.PARAMETER + "2", squeezed[1]);
parameters.remove(ServiceConstants.PARAMETER);
}else
//** END patch **
parameters.put(ServiceConstants.PARAMETER, squeezed);
}
public Object[] extractListenerParameters(IRequestCycle cycle)
{
String[] squeezed =
cycle.getParameters(ServiceConstants.PARAMETER);
//** BEGIN patch **
String s1 = cycle.getParameter(ServiceConstants.PARAMETER + "1");
if(s1 != null){ String s2 =
cycle.getParameter(ServiceConstants.PARAMETER + "2");
squeezed = new String[]{s1, s2};
}
//** END patch **
if (Tapestry.size(squeezed) == 0)
return EMPTY;
try
{
return _dataSqueezer.unsqueeze(squeezed);
}
catch (Exception ex)
{
throw new ApplicationRuntimeException(ex);
}
}
If you would have a better solution for me, which would enable
different query string parameter names for service parameters (instead
of reusing "sp"), I'm open to your suggestions! Otherwise, would you
see how my patch could break some other code elsewhere?
/Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]