• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing extra blank lines from generated html?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing extra blank lines from generated html?


  • Subject: Re: Removing extra blank lines from generated html?
  • From: Lachlan Deck <email@hidden>
  • Date: Sat, 19 Apr 2008 17:54:14 +1000

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Removing extra blank lines from generated html? (From: Alan Zebchuk <email@hidden>)

  • Prev by Date: WOTextField to BigDecimal
  • Next by Date: Re: WOTextField to BigDecimal
  • Previous by thread: Re: Removing extra blank lines from generated html?
  • Next by thread: WOFileUpload
  • Index(es):
    • Date
    • Thread