Hi Alan,
On 19/04/2008, at 7:29 AM, Alan Zebchuk wrote:
Does anyone have a solution for removing the extra blank lines from
the html generated by a component? i.e. when there's a conditional
where the condition is false, the generated html has blank lines
where the conditional would have been.
Another idea FWIW... which enables you to lay out your components a
little nicer (development-wise) and trim surrounding whitespace at
runtime.
Not sure how this would go with Ajax content... Mike would know.
with regards,
--
Lachlan Deck
ISHTrimmedContent.html:
<webobject name = "Content"></webobject>
ISHTrimmedContent.wod:
Content: WOComponentContent {
_unroll = true;
}
public class ISHTrimmedContent
extends
com.ish.webobjects.appserver.ISHStatelessNonSynchronizingComponent
implements
ResponseTransforming
{
private static final org.apache.log4j.Logger LOG =
org.apache.log4j.Logger.getLogger( ISHTrimmedContent.class.getName() );
public static String trimmedString( String value )
{
return ERXStringUtilities.emptyStringForNull( value ).trim();
}
public ISHTrimmedContent( WOContext context )
{
super( context );
}
public WOResponse transformResponseInContext( WOResponse response,
WOContext context )
{
response.setContent( trimmedString( response.contentString() )
);
return response;
}
}
public class ISHComponent
extends
WOComponent
{
public static interface ResponseTransforming
{
public WOResponse transformResponseInContext( WOResponse response,
WOContext context );
}
private static final Logger org.apache.log4j.LOG =
org.apache.log4j.Logger.getLogger( ISHComponent.class );
<...>
public void appendToResponse( WOResponse aResponse, WOContext
aContext )
{
<...>
//
// transform appended content if necessary
// (Note: this may not work with Ajax.framework that manipultes
<head></head>)
//
WOResponse transformedResponse =
ishApplication().createResponseInContext( aContext );
super.appendToResponse( transformedResponse, aContext );
{
if ( this instanceof ResponseTransforming )
transformedResponse =
( ( ResponseTransforming
)this ).transformResponseInContext( transformedResponse, aContext );
<...>
aResponse.appendContentString(
transformedResponse.contentString() );
for ( Enumeration en =
transformedResponse.cookies().objectEnumerator();
en.hasMoreElements(); )
{
WOCookie aCookie = ( WOCookie )en.nextElement();
aResponse.addCookie( aCookie );
}
NSArray headerKeys = transformedResponse.headerKeys();
if ( headerKeys != null )
{
for ( Enumeration en = headerKeys.objectEnumerator();
en.hasMoreElements(); )
{
String headerKey = ( String
)en.nextElement();
NSArray values =
transformedResponse.headersForKey( headerKey );
if ( values != null )
aResponse.appendHeaders(
values, headerKey );
}
}
}
<...>
}
<...>
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]