Changeset 404

Show
Ignore:
Timestamp:
03/19/07 23:49:18 (1 year ago)
Author:
mikey
Message:

added possibility to add default form values

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLPageElement.php

    r267 r404  
    1616interface stubXMLPageElement extends stubPageElement 
    1717{ 
    18     // intentionally empty 
     18    /** 
     19     * returns a list of form values 
     20     * 
     21     * @param   stubRequest           $request 
     22     * @return  array<string,string> 
     23     */ 
     24    public function getFormValues(stubRequest $request); 
    1925} 
    2026?> 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r369 r404  
    5353        $this->writeSessionValues($xmlStreamWriter); 
    5454        $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); 
     55        $formValues    = array(); 
    5556        foreach ($elements as $name => $element) { 
    5657            $prefixRequest->setPrefix($name); 
     
    6162            $data = $element->process($prefixRequest, $this->session, $this->response); 
    6263            $xmlSerializer->serialize($data, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => $name)); 
     64            if ($element instanceof stubXMLPageElement) { 
     65                $formValues[$name] = $element->getFormValues($prefixRequest); 
     66            } 
    6367        } 
     68        $xmlSerializer->serialize($formValues, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => 'forms')); 
    6469        $this->writeRequestValues($xmlStreamWriter, $xmlSerializer); 
    6570 
  • trunk/src/main/resources/xsl/stub.xsl

    r403 r404  
    255255            </xsl:attribute> 
    256256            <xsl:copy-of select="@*[local-name() != 'id' and local-name() != 'name' and local-name() != 'mandatory']"/> 
     257            <ixsl:attribute name="value"> 
     258              <ixsl:if> 
     259                <xsl:attribute name="test"> 
     260                  <xsl:text>/document/forms/</xsl:text> 
     261                  <xsl:value-of select="$id"/> 
     262                  <xsl:text>/</xsl:text> 
     263                  <xsl:value-of select="@name"/> 
     264                </xsl:attribute> 
     265                <ixsl:value-of> 
     266                  <xsl:attribute name="select"> 
     267                    <xsl:text>/document/forms/</xsl:text> 
     268                    <xsl:value-of select="$id"/> 
     269                    <xsl:text>/</xsl:text> 
     270                    <xsl:value-of select="@name"/> 
     271                  </xsl:attribute> 
     272                </ixsl:value-of> 
     273              </ixsl:if> 
     274            </ixsl:attribute> 
    257275          </input> 
    258276        </xsl:when> 
     
    272290            <xsl:apply-templates select="node()"> 
    273291              <xsl:with-param name="id" select="@id"/> 
     292              <xsl:with-param name="name" select="@name"/> 
    274293            </xsl:apply-templates>             
    275294          </select> 
     
    289308            <xsl:copy-of select="@*[local-name() != 'id' and local-name() != 'name' and local-name() != 'mandatory' and local-name() != 'type']"/> 
    290309            <xsl:apply-templates select="text()"/> 
     310            <ixsl:if> 
     311              <xsl:attribute name="test"> 
     312                <xsl:text>/document/forms/</xsl:text> 
     313                <xsl:value-of select="$id"/> 
     314                <xsl:text>/</xsl:text> 
     315                <xsl:value-of select="@name"/> 
     316              </xsl:attribute> 
     317              <ixsl:value-of> 
     318                <xsl:attribute name="select"> 
     319                  <xsl:text>/document/forms/</xsl:text> 
     320                  <xsl:value-of select="$id"/> 
     321                  <xsl:text>/</xsl:text> 
     322                  <xsl:value-of select="@name"/> 
     323                </xsl:attribute> 
     324              </ixsl:value-of> 
     325            </ixsl:if> 
    291326          </textarea> 
    292327        </xsl:when> 
     
    347382  <xsl:template match="stub:option" name="stub:option"> 
    348383    <xsl:param name="id" select="@id"/> 
     384    <xsl:param name="name" select="@name"/> 
    349385    <option> 
    350386      <xsl:copy-of select="@*"/>       
    351387      <xsl:apply-templates select="text()"/> 
     388      <ixsl:if> 
     389        <xsl:attribute name="test"> 
     390          <xsl:text>/document/forms/</xsl:text> 
     391          <xsl:value-of select="$id"/> 
     392          <xsl:text>/</xsl:text> 
     393          <xsl:value-of select="$name"/> 
     394        </xsl:attribute> 
     395        <ixsl:attribute name="selected"> 
     396          <ixsl:value-of> 
     397             <xsl:text>selected</xsl:text> 
     398          </ixsl:value-of> 
     399        </ixsl:attribute> 
     400      </ixsl:if> 
    352401    </option> 
    353402  </xsl:template> 
  • trunk/src/test/php/net/stubbles/websites/xml/stubXMLProcessorTestCase.php

    r317 r404  
    124124        $this->mockXMLStreamWriter->expectCallcount('writeStartElement', 4); 
    125125        $this->mockXMLStreamWriter->expectCallcount('writeEndElement', 4); 
    126         $this->mockXMLSerializer->expectNever('serialize'); 
     126        $this->mockXMLSerializer->expectOnce('serialize'); 
    127127        $return = $this->xmlProcessor->process(); 
    128128        $this->assertReference($this->xmlProcessor, $return);