[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] html/form på mobil



On Monday 06 August 2007 00:47:02 Atte André Jensen wrote:
> Hejsa
>
> Jeg vil gerne lave en form som kan tilgås, redigeres, submites og
> reageres på via min mobil-tlf. Lige nu har jeg flg index.php (online:
> http://atte.dk/mobil):
>
> <?
> if(isset($_GET['abc'])){
>      $content = $_GET['abc'];
>   } else {
>
>      $content .= '<form >';
>      $content .= '<input name="abc">';
>      $content .= '<input type="submit">';
>      $content .= '</form>';
>   }
>
> echo $content;
> ?>
>

du kallar filen index.wml, vilket gör att den inte processas av PHP, så 
web/wap-läsaren får den råa PHP koden. Dessutom sätter du content till 
text/html, när det borde vara 'text/vnd.wap.wml' (se java snutt)

>
> Har osse kikket på wml, men jeg kan heller ikke få det til at virke.
>
Det hälper inte att bara döpa om till .wml, innehållet måste vara wml med


> Hvis jeg besøger google.dk på mobilen, er det ikke helt det samme
> indhold som i firefox. Hvad er det der gør forskellen og hvordan får jeg
> firefox til at vise sider som min mobil?

Server tittar tex på 
och använder det som (Lite javaexempel, kör i min garderob)

    // Set to expire far in the past.
                response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
                // Set standard HTTP/1.1 no-cache headers.
                response.setHeader("Cache-Control", "no-store, no-cache, 
must-revalidate");
                // Set standard HTTP/1.0 no-cache header.
                response.setHeader("Pragma", "no-cache");
                int clientType = determineClientType(request);
                int mode = 4; //to make it think is going to be meny
                File xsltFile = locateStyleSheet(clientType, mode);
                switch (clientType) {
                        case WML_CLIENT_TYPE : {
                                response.setContentType("text/vnd.wap.wml");
                                break;
                        }
                        case XHTML_CLIENT_TYPE  :{
                                response.setContentType("text/html");
                                break;
                        }
                }

där determinClientType ser ut som
 private int determineClientType(HttpServletRequest req) {
                int ct = 0;
                String userAgent = req.getHeader("User-Agent");
                if (userAgent != null && 
userAgent.toLowerCase().startsWith("mozilla")) {
                        ct = XHTML_CLIENT_TYPE;
                }

                String accept = req.getHeader("Accept");
                if (ct == 0 && accept != null && 
accept.indexOf("text/vnd.wap.wml") > -1) {
                        ct = WML_CLIENT_TYPE;
                }

                if (ct == 0) ct = XHTML_CLIENT_TYPE;
                dbg.print("Clienttype= " + Integer.toString(ct));
                return ct;
        }




vill du enkelt få ut lite giltig wml,
så ta hem en cgi-script jag gjorde i tcl för många år sedan.

wget http://lundin.homelinux.net/bensin.tcl

skapa en (skrivbar) dat-file som ser ut ungefär så här

cat bensin.dat
26-Apr-07 48.16 28343
19-May-07 48.53 28954
06-Jun-07 49.56 29610
12-Jul-07 48.15 30235
25-Jul-07 48.50 30863



testkör med tclsh bensin.tcl. Borde get något som
<?xml version
  ='1.0'?>
<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN'
'http://www.wapforum.org/DTD/wml_1.1.xml'>
<wml>

  <card id='show' title='Data'>
    <p>Datum Liter Km <b> Medel</b><br/>
Array is not loaded<br/></p>
     <p><do type='accept' label='Ny tankning'>
      <go href='#insert_form'/>
    </do></p>

  </card>


  <card id='insert_form' title='Ny post'>
     <p>      Datum: <input name='d' size='11' maxlength='15' 
value='06-aug-07'/                                                   >
      km:    <input name='k' size='6' maxlength='10'/>
      Liter: <input name='l' size='5' maxlength='7'/>
    <do type='accept' label='Skicka data'>
      <go href='bensin.tcl'>
        <postfield name='datum' value='$d'/>
        <postfield name='liter' value='$l'/>
        <postfield name='km' value='$k'/>
      </go>
    </do>
</p>
  </card>


</wml>


tittar du i koden ser du att genom att sätt QUERY_STRING kan du simulera ett 
formulär som körs med GET

sslug@sslug:/tmp$ export QUERY_STRING='datum=2007-08-05&liter=34&km=520'
sslug@sslug:/tmp$ tclsh bensin.tcl
Content-type: text/vnd.wap.wml
Cache-Control: no-cache
Cache-Control: must-revalidate




<?xml version
  ='1.0'?>
<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN'
'http://www.wapforum.org/DTD/wml_1.1.xml'>
<wml>

  <card id='data_added' title='Data lagrad'>
    <p>Data lagrad <b> OK</b>
<br/><a href='bensin.tcl'>Visa resultat</a></p>
  </card>


</wml>


och så har den skrivit lite i bensin.dat



-- 
/Björn





 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *