日期:2014-05-16 浏览次数:20421 次
<?xml version="1.0" encoding="UTF-8"?> <pages xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd" no-conversation-view-id="/main.xhtml" login-view-id="/home.xhtml"> <page view-id="/testJson.xhtml"> <param name="user" value="#{myDate.user}"/> </page> </pages>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>TEST</title> </head> <body> <script type="text/javascript"> function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function testSubmit(){ xmlHttp=GetXmlHttpObject() if (xmlHttp==null){ alert ("您的浏览器不支持AJAX!"); return; } var u=document.getElementById("user"); var url="testJson.seam"; url=url+"?user="+u.value; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4){ var req=xmlHttp.responseText; document.getElementById("test").innerHTML=req; } } </script> <form action="testJson.seam"> <input id="user" type="text" name="user"/> <input type="button" value="ajax" onClick="testSubmit()"/> <input type="submit" value="submit"/> <span id="test"></span> </form> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>TEST</title> </head> <body> hello!#{myDate.user} </body> </html>
package test; import org.jboss.seam.annotations.*; import org.jboss.seam.ScopeType; @Name("myDate") @Scope(ScopeType.CONVERSATION) public class MyDate{ String user; public String getUser(){ return user; } public void setUser(String user){ this.user=user; } }