[Ur] Problem including modules

David Snider david at davidsnider.net
Fri Dec 11 21:10:27 EST 2009


I'm messing around with Ur and I was trying to include one of your modules
from the tutorials into my application.

It seems your module has links that return entirely new pages (starting
from body) and I just want it to return fragments so I can have these
templated "Master Pages"

Any suggestions?


datatype masterPageMode = Normal | NoLeft

fun masterPage pageType header left right footer = 
    case pageType of 
	Normal => return <xml>
	  <head>
	    <title>CRM Application</title>
	  </head>
	  <body>
	    <div>{header}</div>
	    <div>{left}</div>
	    <div>{right}</div>
	    <div>{footer}</div>
	  </body>
	</xml>
	| NoLeft => return <xml>
	  <head>
	    <title>Login</title>
	  </head>
	  <body>
	    <div>{header}</div>
	    <div>{right}</div>
	    <div>{footer}</div>
	  </body>
	 </xml>

val header = <xml>HEADER</xml>
val left = <xml>LEFT</xml>
val footer = <xml>FOOTER</xml>

fun masterPage' pageType left right = masterPage pageType header left right
footer

table users : { Id : int, Username : string, Password : string} PRIMARY KEY
Id

structure UsersCRUD = Crud.Make(struct
                   val tab = users
                             
                   val title = "Users"
                               
                   val cols = {
                               Username = Crud.string "Username",
			       Password = Crud.string "Password"
			      }
               end)


fun register () = 
    reg <- UsersCRUD.main ();
    masterPage' NoLeft <xml/> reg


fun welcome r = return <xml>
Hello {[r.Login]}, I can see your password: {[r.Password]}
</xml>

fun login () = return <xml>
  <div>
    <form>
      Login: <textbox {#Login} /><br/>
      Password: <textbox {#Password} /><br/>
      <submit action={handler}/><br/>
      Not Registered? <a link={register ()}>Click Here</a>
    </form>
  </div>
</xml>

and handler r = 
    msg <- welcome r;
    masterPage' Normal left msg

fun main () = 
l <- login();
masterPage' NoLeft (<xml/>) l




More information about the Ur mailing list