我有问题。
如何从静态方法<div id="home" class="tab-pane col-md-9 fade in active "><div class="row bordo spazio">
<p><strong><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Modifica dati</strong></p>
<hr/>
<?php echo $this->session->flashdata('msg'); ?>
<div class=" well">
<?php $attributes = array("name" => "signupform");
echo form_open("modificacollaboratore/index", $attributes); ?>
<legend><h3>Modifica dati</h3></legend>
<label for="titolo">Titolo</label>
<div class="form-group">
<div class="radio-inline"> <input type="radio" name="titolo" value="Signor" checked> Signor </div>
<div class="radio-inline"> <input type="radio" name="titolo" value="Signora"> Signora </div>
<div class="radio-inline"> <input type="radio" name="titolo" value="Ditta"> Ditta </div>
<span class="text-danger"><?php echo form_error('titolo'); ?></span>
</div>
<div class="form-group">
<input class="form-control" name="userid" type="hidden" value="<?php echo $this->input->post('userid'); ?>" />
</div>
<div class="form-group">
<label for="fname">Nome</label>
<input class="form-control" name="fname" placeholder="<?php $fname; ?>" type="text" value="<?php echo $fname;//echo set_value('fname'); ?>" />
<span class="text-danger"><?php echo form_error('fname'); ?></span>
</div>
<div class="form-group">
<label for="lname">Cognome</label>
<input class="form-control" name="lname" placeholder="<?php //echo $lname; ?>" type="text" value="<?php echo $lname; //echo set_value('lname'); ?>" />
<span class="text-danger"><?php echo form_error('lname'); ?></span>
</div>
<div class="form-group">
<label for="via">Via</label>
<input class="form-control" name="via" placeholder="" type="text" value="<?php echo $uvia;//echo set_value('via'); ?>" />
<span class="text-danger"><?php echo form_error('via'); ?></span>
</div>
<div class="form-group">
<label for="cap">CAP</label>
<input class="form-control" name="cap" placeholder="" type="text" value="<?php echo $ucap //set_value('cap'); ?>" />
<span class="text-danger"><?php echo form_error('cap'); ?></span>
</div>
<div class="form-group">
<label for="citta">Città</label>
<input class="form-control" name="citta" placeholder="" type="text" value="<?php echo $ucitta;//set_value('citta'); ?>" />
<span class="text-danger"><?php echo form_error('citta'); ?></span>
</div>
<div class="form-group">
<label for="teleditta">Telefono ditta</label>
<input class="form-control" name="teleditta" placeholder="" type="text" value="<?php echo $uteleditta; //set_value('teleditta'); ?>" />
<span class="text-danger"><?php echo form_error('teleditta'); ?></span>
</div>
<div class="form-group">
<label for="cellulare">Cellulare</label>
<input class="form-control" name="cellulare" placeholder="" type="text" value="<?php echo $ucellulare; //set_value('cellulare'); ?>" />
<span class="text-danger"><?php echo form_error('cellulare'); ?></span>
</div>
<div class="form-group">
<label for="subject">Valido dal</label>
<input type="date" name="valido" value="<?php echo $uvalido//set_value('valido'); ?>" style="width:100%">
<span class="text-danger"><?php echo form_error('valido'); ?></span>
</div>
<div class="form-group">
<button name="submit" type="submit" class="btn btn-info">Modifica</button>
<button name="cancel" type="reset" class="btn btn-info">Cancella</button>
</div>
<?php echo form_close(); ?>
<?php echo $this->session->flashdata('msg'); ?>
</div>
</div>
</div>
<div id="menu1" class="tab-pane col-md-9 fade">
<h3>Provvigioni</h3>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div id="menu2" class="tab-pane col-md-9 fade">
<div class="row bordo spazio">
<p><strong><i class="fa fa-handshake-o" aria-hidden="true"></i> Partners Commerciali</strong></p>
<hr/>
<p><a href="aggiungi"><i class="fa fa-share" aria-hidden="true"></i> Nuovo collaboratore</a></p>
</div>
</div>
<div id="menu3" class="tab-pane col-md-9 fade">
<div class="row bordo spazio">
<p><strong><i class="fa fa-address-card-o" aria-hidden="true"></i> Clienti</strong></p>
<hr/>
<p><a href="intervista"><i class="fa fa-share" aria-hidden="true"></i> Nuova intervista</a></p>
</div>
</div>
<div id="menu4" class="tab-pane col-md-9 fade">
<h3>Documenti</h3>
<p>Eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
</div>
<div id="menu5" class="tab-pane col-md-9 fade">
<div class="row bordo spazio">
<p><strong><i class="fa fa-address-book-o" aria-hidden="true"></i> Profilo</strong></p>
<hr/>
<p><i class="fa fa-user-o" aria-hidden="true"></i> <?php echo $uname; ?></p>
<p><i class="fa fa-envelope-o" aria-hidden="true"></i> <?php echo $uemail; ?></p>
<p><a href="modifica"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Impostazioni</a></p>
</div>
</div>
收集数据并将其传递给makeFrom
方法,然后将其传递给filter
方法而不创建静态字段,以便我可以像这样使用此类{{1 }}?
map
答案 0 :(得分:1)
它基本上是一个构建器模式。你可以使它比我的例子复杂得多 - 如果你想强制调用一个命令,或者必须阻止一个操作在另一个调用之后被调用,例如。
看起来应该是这样的:
public class ListMaker<T> { // no guarantee about the generics, didn't have a compiler here.
private List<?> newList;
// CTOR: initialize internal state.
private ListMaker( List<T> list ){
newList = new ArrayList<T>();
newList.addAll(list);
}
// Factory method: Create ListMaker
public static <T> ListMaker<T> makeFrom(List<T> list){
ListMaker lm = new ListMaker( list );
return lm;
}
// apply filter
public ListMaker<T> filter(Filter<T> filter){
newList = filter.apply(newList); // <- interface? Just making something up
return this;
}
// apply mapper
public ListMaker<T> map(Mapper<N,T> map){
newList = map.apply(newList); // <- interface? Just making something up
return this;
}
// terminator to retrieve the result
public List<T> toList(){
return newList;
}
}
注意:如果不了解所有接口和签名,我必须做些准备。但是我希望你能得到它的主旨。
然后可以使用它:
List<String> strList = ListMaker.makeFrom(source) // now we have an instance of ListMaker
// on which we call the rest
.filter(myFilter) // modifys newList and returns itself
.map(myMapping) // modifys newList and returns itself
.toList(); // now we can return the result List.