def url_for(params = {})
      return params.to_s if params.is_a?( String ) or params.is_a?( Symbol )
      return '/' if not params.is_a?( Hash ) or params.nil?

      params = params.symbolize_keys if params.is_a? Hash

      application = params[:application] || @request['application']
      model = params[:controller] || params[:model] || @request['model'] 
      action = params[:action].nil? ? nil : params[:action].to_s
      id = params[:id].nil? ? nil : params[:id].to_s
      id = "{#{id}}" if id and not( id =~ /^{/ and id =~ /}$/ )

      if params[:query_s]
        query = params[:query_s]
      else
        query = query_to_s(params[:query])
      end
        
      fragment = params[:fragment].nil? ? '' : '#' + params[:fragment]
   
      amurl = ''
      amurl << '/' << application.to_s << '/' if application
      amurl << model.to_s

      is_bb6 = System::get_property('platform') == 'Blackberry' && (System::get_property('os_version').split('.')[0].to_i >= 6)
      if action.nil? or ( !is_bb6 && action == 'create' ) or action == 'index'
        amurl << query << fragment
      else
        amurl << '/' << (id.nil? ? action : id + '/' + action) << query << fragment          
      end
        
      amurl
      
      #amurl = '/' + application.to_s + '/' + model.to_s

      #return amurl + query + fragment if action.nil? or action == 'create' or action == 'index'
      #return amurl +'/'+ (id.nil? ? action : id + '/' + action) + query + fragment
    end
def url_for(params = {})
      return params.to_s if params.is_a?( String ) or params.is_a?( Symbol )
      return '/' if not params.is_a?( Hash ) or params.nil?

      params = params.symbolize_keys if params.is_a? Hash

      application = params[:application] || @request['application']
      model = params[:controller] || params[:model] || @request['model'] 
      action = params[:action].nil? ? nil : params[:action].to_s
      id = params[:id].nil? ? nil : params[:id].to_s
      id = "{#{id}}" if id and not( id =~ /^{/ and id =~ /}$/ )

      if params[:query_s]
        query = params[:query_s]
      else
        query = query_to_s(params[:query])
      end
        
      fragment = params[:fragment].nil? ? '' : '#' + params[:fragment]
   
      amurl = ''
      amurl << '/' << application.to_s << '/' if application
      amurl << model.to_s

      is_bb6 = System::get_property('platform') == 'Blackberry' && (System::get_property('os_version').split('.')[0].to_i >= 6)
      if action.nil? or ( !is_bb6 && action == 'create' ) or action == 'index'
        amurl << query << fragment
      else
        amurl << '/' << (id.nil? ? action : id + '/' + action) << query << fragment          
      end
        
      amurl
      
      #amurl = '/' + application.to_s + '/' + model.to_s

      #return amurl + query + fragment if action.nil? or action == 'create' or action == 'index'
      #return amurl +'/'+ (id.nil? ? action : id + '/' + action) + query + fragment
    end
Examples of how to use url_for method:

 url_for '/some_url'
 ==> /some_url

 When generating a new URL, missing values may be filled in from the current request's parameters.
 For example, if application name or model are not specifyed in the call parameters, they would be filled from the request.

 url_for :action => :index
 ==> /application/model

 url_for :action => :create
 ==> /application/model

 url_for :action => :new
 ==> /application/model/new

 url_for :action => :show, :id => '{12}'
 ==> /application/model/{12}/show

 url_for :model => :another_model, :action => :show, :id => '{12}'
 ==> /application/another_model/{12}/show

 url_for :controller => :another_controller, :action => :show, :id => '{12}'
 ==> /application/another_controller/{12}/show

 url_for :application => :another_app, :model => :another_model, :action => :show, :id => '{12}'
 ==> /another_app/another_model/{12}/show

 url_for :action => :create, :query => {:name => 'John Smith', 'address' => "http://john.smith.com"}
 ==> /application/model?name=John%20Smith&address=http%3A%2F%2Fjohn.smith.com

 url_for :action => :show, :id => '{12}', :fragment => "an-anchor"
 ==> /application/model/{12}/show#an-anchor